Skip to content

Commit

Permalink
wait until next tick to satisfy Firefox; remove extra tick
Browse files Browse the repository at this point in the history
  • Loading branch information
machenmusik committed Feb 7, 2017
1 parent 344a5b5 commit 5d719c1
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions tests/components/raycaster.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,16 @@ suite('raycaster', function () {
});

targetEl.setAttribute('geometry', 'primitive: box; depth: 1; height: 1; width: 1;');
targetEl.setAttribute('material', '');
targetEl.setAttribute('position', '0 0 -1');
el.sceneEl.appendChild(targetEl);
// `npm run test:chrome` only works if addEventListener added after appendChild.
targetEl.addEventListener('loaded', function finishSetup () {
done();
});
// `npm run test:forefox` needs the timeout for the tests to succeed.
function finishSetup () { setTimeout(function () { done(); }, 0); }
if (targetEl.hasLoaded) { finishSetup(); } else { targetEl.addEventListener('loaded', finishSetup); }
});

test('can catch basic intersection', function (done) {
this.targetEl.addEventListener('raycaster-intersected', function () { done(); });
this.el.sceneEl.tick();
this.el.sceneEl.tick();
});

test('updates intersectedEls', function (done) {
Expand Down Expand Up @@ -247,15 +244,17 @@ suite('raycaster', function () {
});

targetEl.setAttribute('geometry', 'primitive: box; depth: 1; height: 1; width: 1;');
targetEl.setAttribute('material', '');
targetEl.setAttribute('position', '0 0 -1');
el.sceneEl.appendChild(targetEl);
// `npm run test:chrome` only works if addEventListener added after appendChild.
targetEl.addEventListener('loaded', function finishSetup () {
// The object to check raycast against should reference the entity.
assert.equal(targetEl, targetEl.object3D.children[0].el);
done();
});
// `npm run test:forefox` needs the timeout for the tests to succeed.
function finishSetup () {
setTimeout(function () {
// The object to check raycast against should reference the entity.
assert.equal(targetEl, targetEl.object3D.children[0].el);
done();
}, 0);
}
if (targetEl.hasLoaded) { finishSetup(); } else { targetEl.addEventListener('loaded', finishSetup); }
});

test('can catch basic intersection', function (done) {
Expand Down

0 comments on commit 5d719c1

Please sign in to comment.