forked from aframevr/aframe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
system.test.js
99 lines (82 loc) · 2.47 KB
/
system.test.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* global AFRAME, assert, process, suite, test, setup */
var components = require('core/component').components;
var systems = require('core/system').systems;
var registerSystem = require('core/system').registerSystem;
var TestSystem = {
init: function () {}
};
suite('System', function () {
suite('standard systems', function () {
test('are registered', function () {
assert.ok('material' in systems);
});
});
suite('system registration', function () {
setup(function () {
delete systems.test;
});
test('can be registered', function () {
assert.notOk('TestSystem' in systems);
registerSystem('test', TestSystem);
assert.ok('test' in systems);
});
});
suite('schema', function () {
setup(function () {
delete components.test;
delete systems.test;
});
test('initializes data for single-prop schema', function () {
var sceneEl = document.createElement('a-scene');
var system;
var TestSystem;
AFRAME.registerSystem('test', {
schema: {default: ''}
});
TestSystem = systems.test;
sceneEl.setAttribute('test', 'candy');
system = new TestSystem(sceneEl);
assert.equal(system.data, 'candy');
});
test('initializes data for multi-prop schema', function () {
var sceneEl = document.createElement('a-scene');
var system;
var TestSystem;
AFRAME.registerSystem('test', {
schema: {
a: {type: 'number'},
b: {type: 'string'}
}
});
TestSystem = systems.test;
sceneEl.setAttribute('test', 'a: 50; b: horses');
system = new TestSystem(sceneEl);
assert.equal(system.data.a, 50);
assert.equal(system.data.b, 'horses');
});
test('uses default values', function () {
var sceneEl = document.createElement('a-scene');
var system;
var TestSystem;
AFRAME.registerSystem('test', {
schema: {
a: {default: 50},
b: {default: 'horses'}
}
});
TestSystem = systems.test;
system = new TestSystem(sceneEl);
assert.equal(system.data.a, 50);
assert.equal(system.data.b, 'horses');
});
test('can be empty', function () {
var sceneEl = document.createElement('a-scene');
var system;
var TestSystem;
AFRAME.registerSystem('test', {schema: {}});
TestSystem = systems.test;
system = new TestSystem(sceneEl);
assert.notOk(system.data);
});
});
});