forked from aframevr/aframe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init.test.js
More file actions
59 lines (53 loc) · 1.71 KB
/
__init.test.js
File metadata and controls
59 lines (53 loc) · 1.71 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
48
49
50
51
52
53
54
55
56
57
58
59
/* 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 = {
cancelAnimationFrame: function (h) { return window.cancelAnimationFrame(1); },
capabilities: {},
exitPresent: resolvePromise,
getPose: function () { return { orientation: null, position: null }; },
requestAnimationFrame: function () { return 1; },
requestPresent: resolvePromise,
submitFrame: function () { return; }
};
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');
// Mock renderer.
AScene.prototype.renderer = {
vr: {
getDevice: function () { return {requestPresent: function () {}}; },
setDevice: function () {},
setPoseTarget: function () {},
enabled: false
},
getContext: function () { return undefined; },
shadowMap: {}
};
});
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();
});
});