This repository was archived by the owner on Oct 18, 2025. It is now read-only.
forked from aframevr/aframe
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy path__init.test.js
More file actions
47 lines (41 loc) · 1.38 KB
/
__init.test.js
File metadata and controls
47 lines (41 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* global AFRAME, sinon, setup, teardown */
/**
* __init.test.js is run before every test case.
*/
window.debug = true;
navigator.getVRDisplays = function () {
var resolvePromise = Promise.resolve();
var mockVRDisplay = {
requestPresent: resolvePromise,
exitPresent: resolvePromise,
submitFrame: function () { return; },
getPose: function () { return { orientation: null, position: null }; },
requestAnimationFrame: function () { return 1; },
cancelAnimationFrame: function (h) { return window.cancelAnimationFrame(1); }
};
return Promise.resolve([mockVRDisplay]);
};
require('index');
var AScene = require('core/scene/a-scene').AScene;
setup(function () {
this.sinon = sinon.sandbox.create();
// Stubs to not create a WebGL context since Travis CI runs headless.
this.sinon.stub(AScene.prototype, 'render');
this.sinon.stub(AScene.prototype, 'resize');
this.sinon.stub(AScene.prototype, 'setupRenderer');
});
teardown(function (done) {
// Clean up any attached elements.
var attachedEls = ['canvas', 'a-assets', 'a-scene'];
var els = document.querySelectorAll(attachedEls.join(','));
for (var i = 0; i < els.length; i++) {
els[i].parentNode.removeChild(els[i]);
}
this.sinon.restore();
delete AFRAME.components.test;
delete AFRAME.systems.test;
// Allow detachedCallbacks to clean themselves up.
setTimeout(function () {
done();
});
});