Skip to content

Commit

Permalink
Unit tests for aframevr#5242
Browse files Browse the repository at this point in the history
  • Loading branch information
diarmidmackenzie authored and mrxz committed Mar 23, 2024
1 parent 696aba6 commit 747fa17
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/core/component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,37 @@ suite('Component', function () {
component.updateProperties({list: ['b']});
component.updateProperties({list: ['b']});
sinon.assert.calledOnce(updateStub);
assert.deepEqual(component.data.list, ['b']);
});

test('supports array property on entity creation', function (done) {
entityFactory();
registerComponent('dummy', {
schema: { list: {type: 'array', default: ['a']} }
});
var scene = document.querySelector('a-scene');
var el2 = document.createElement('a-entity');
el2.setAttribute('dummy', { list: ['b', 'c', 'd'] });
el2.addEventListener('componentinitialized', evt => {
assert.deepEqual(el2.components.dummy.data.list, ['b', 'c', 'd']);
done();
});
scene.appendChild(el2);
});

test('supports array property in single property schema on entity creation', function (done) {
entityFactory();
registerComponent('dummy', {
schema: {type: 'array', default: ['a']}
});
var scene = document.querySelector('a-scene');
var el2 = document.createElement('a-entity');
el2.setAttribute('dummy', ['b', 'c', 'd']);
el2.addEventListener('componentinitialized', () => {
assert.deepEqual(el2.components.dummy.data, ['b', 'c', 'd']);
done();
});
scene.appendChild(el2);
});

test('emit componentchanged when update calls setAttribute', function (done) {
Expand Down

0 comments on commit 747fa17

Please sign in to comment.