-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
239 lines (218 loc) · 11.2 KB
/
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
var assert = require('assert'),
zonegrid = require('zonegrid'),
zone;
describe('zonegrid', function() {
before(function (done) {
zone = zonegrid.createZone();
zone.on('ready', function() {
done();
});
});
describe('.id', function() {
it('should fail to set the ID property of a zone', function() {
zone.id = 123456789;
assert.notEqual(zone.id, 123456789);
});
});
describe('.name', function() {
it('should set the name of a zone', function() {
zone.name = 'zone';
assert.equal(zone.name, 'zone');
});
});
describe('.size', function() {
it('should set the size of a zone', function() {
zone.size.x = 100;
zone.size.y = 200;
zone.size.z = 300;
assert.equal(zone.size.x, 100);
assert.equal(zone.size.y, 200);
assert.equal(zone.size.z, 300);
});
});
// describe('.limits', function() {
// it('should fail to set the limits of a zone', function() {
// var limit = 100000;
// zone.limits.x.lower = -limit;
// zone.limits.x.higher = limit;
// zone.limits.y.lower = -limit;
// zone.limits.y.higher = limit;
// zone.limits.z.lower = -limit;
// zone.limits.z.higher = limit;
// assert.notEqual(zone.limits.x.lower, -limit);
// assert.notEqual(zone.limits.x.lower, limit);
// assert.notEqual(zone.limits.y.lower, -limit);
// assert.notEqual(zone.limits.y.higher, limit);
// assert.notEqual(zone.limits.z.lower, -limit);
// assert.notEqual(zone.limits.z.higher, limit);
// });
// });
describe('.coordinates', function() {
it('should ]set the coordinates of a zone', function() {
var higherX = zone.limits.x.higher;
var higherY = zone.limits.y.higher;
var higherZ = zone.limits.z.higher;
zone.coordinates.x = 100;
zone.coordinates.y = 200;
zone.coordinates.z = 300;
assert.equal(zone.coordinates.x, 100);
assert.equal(zone.coordinates.y, 200);
assert.equal(zone.coordinates.z, 300);
assert.equal(zone.limits.x.higher, higherX + 100);
assert.equal(zone.limits.y.higher, higherY + 200);
assert.equal(zone.limits.z.higher, higherZ + 300);
});
});
describe('.visibility', function() {
it('should set the visibility of a zone', function() {
zone.visibility.x = 100;
zone.visibility.y = 200;
zone.visibility.z = 300;
assert.equal(zone.visibility.x, 100);
assert.equal(zone.visibility.y, 200);
assert.equal(zone.visibility.z, 300);
assert.equal(zone.margins.scope.inner.x.lower - zone.limits.x.lower, zone.visibility.x);
assert.equal(zone.margins.scope.inner.x.higher - zone.limits.x.higher, -zone.visibility.x);
assert.equal(zone.margins.scope.outer.x.lower - zone.limits.x.lower, -zone.visibility.x);
assert.equal(zone.margins.scope.outer.x.higher - zone.limits.x.higher, zone.visibility.x);
assert.equal(zone.margins.scope.inner.y.lower - zone.limits.y.lower, zone.visibility.y);
assert.equal(zone.margins.scope.inner.y.higher - zone.limits.y.higher, -zone.visibility.y);
assert.equal(zone.margins.scope.outer.y.lower - zone.limits.y.lower, -zone.visibility.y);
assert.equal(zone.margins.scope.outer.y.higher - zone.limits.y.higher, zone.visibility.y);
});
});
describe('.handover', function() {
it('should set the handover value of a zone', function() {
zone.handover = 10;
assert.equal(zone.handover, 10);
assert.equal(zone.margins.handover.bookin.x.lower, zone.limits.x.lower + zone.handover);
assert.equal(zone.margins.handover.bookin.x.higher, zone.limits.x.higher - zone.handover);
assert.equal(zone.margins.handover.bookin.y.lower, zone.limits.y.lower + zone.handover);
assert.equal(zone.margins.handover.bookin.y.higher, zone.limits.y.higher - zone.handover);
assert.equal(zone.margins.handover.bookin.z.lower, zone.limits.z.lower + zone.handover);
assert.equal(zone.margins.handover.bookin.z.higher, zone.limits.z.higher - zone.handover);
assert.equal(zone.margins.handover.checkin.x.lower, zone.limits.x.lower - zone.handover);
assert.equal(zone.margins.handover.checkin.x.higher, zone.limits.x.higher + zone.handover);
assert.equal(zone.margins.handover.checkin.y.lower, zone.limits.y.lower - zone.handover);
assert.equal(zone.margins.handover.checkin.y.higher, zone.limits.y.higher + zone.handover);
assert.equal(zone.margins.handover.checkin.z.lower, zone.limits.z.lower - zone.handover);
assert.equal(zone.margins.handover.checkin.z.higher, zone.limits.z.higher + zone.handover);
});
});
// describe('.margins.scope.inner', function() {
// it('should fail to set the inner scope margins of a zone', function() {
// var newMargin = 100000;
// zone.margins.scope.inner.x.lower = -newMargin;
// zone.margins.scope.inner.x.higher = newMargin;
// zone.margins.scope.inner.y.lower = -newMargin;
// zone.margins.scope.inner.y.higher = newMargin;
// zone.margins.scope.inner.z.lower = -newMargin;
// zone.margins.scope.inner.z.higher = newMargin;
// assert.notEqual(zone.margins.scope.inner.x.lower, -newMargin);
// assert.notEqual(zone.margins.scope.inner.x.higher, newMargin);
// assert.notEqual(zone.margins.scope.inner.y.lower, -newMargin);
// assert.notEqual(zone.margins.scope.inner.y.higher, newMargin);
// assert.notEqual(zone.margins.scope.inner.z.lower, -newMargin);
// assert.notEqual(zone.margins.scope.inner.z.higher, newMargin);
// });
// });
// describe('.margins.scope.outer', function() {
// it('should fail to set the inner scope margins of a zone', function() {
// var newMargin = 100000;
// zone.margins.scope.outer.x.lower = -newMargin;
// zone.margins.scope.outer.x.higher = newMargin;
// zone.margins.scope.outer.y.lower = -newMargin;
// zone.margins.scope.outer.y.higher = newMargin;
// zone.margins.scope.outer.z.lower = -newMargin;
// zone.margins.scope.outer.z.higher = newMargin;
// assert.notEqual(zone.margins.scope.outer.x.lower, -newMargin);
// assert.notEqual(zone.margins.scope.outer.x.higher, newMargin);
// assert.notEqual(zone.margins.scope.outer.y.lower, -newMargin);
// assert.notEqual(zone.margins.scope.outer.y.higher, newMargin);
// assert.notEqual(zone.margins.scope.outer.z.lower, -newMargin);
// assert.notEqual(zone.margins.scope.outer.z.higher, newMargin);
// });
// });
// describe('.margins.handover.bookin', function() {
// it('should fail to set the inner scope margins of a zone', function() {
// var newMargin = 100000;
// zone.margins.handover.bookin.x.lower = -newMargin;
// zone.margins.handover.bookin.x.higher = newMargin;
// zone.margins.handover.bookin.y.lower = -newMargin;
// zone.margins.handover.bookin.y.higher = newMargin;
// zone.margins.handover.bookin.z.lower = -newMargin;
// zone.margins.handover.bookin.z.higher = newMargin;
// assert.notEqual(zone.margins.handover.bookin.x.lower, -newMargin);
// assert.notEqual(zone.margins.handover.bookin.x.higher, newMargin);
// assert.notEqual(zone.margins.handover.bookin.y.lower, -newMargin);
// assert.notEqual(zone.margins.handover.bookin.y.higher, newMargin);
// assert.notEqual(zone.margins.handover.bookin.z.lower, -newMargin);
// assert.notEqual(zone.margins.handover.bookin.z.higher, newMargin);
// });
// });
// describe('.margins.handover.checkin', function() {
// it('should fail to set the inner scope margins of a zone', function() {
// var newMargin = 100000;
// zone.margins.handover.checkin.x.lower = -newMargin;
// zone.margins.handover.checkin.x.higher = newMargin;
// zone.margins.handover.checkin.y.lower = -newMargin;
// zone.margins.handover.checkin.y.higher = newMargin;
// zone.margins.handover.checkin.z.lower = -newMargin;
// zone.margins.handover.checkin.z.higher = newMargin;
// assert.notEqual(zone.margins.handover.checkin.x.lower, -newMargin);
// assert.notEqual(zone.margins.handover.checkin.x.higher, newMargin);
// assert.notEqual(zone.margins.handover.checkin.y.lower, -newMargin);
// assert.notEqual(zone.margins.handover.checkin.y.higher, newMargin);
// assert.notEqual(zone.margins.handover.checkin.z.lower, -newMargin);
// assert.notEqual(zone.margins.handover.checkin.z.higher, newMargin);
// });
// });
describe('.elements#add', function() {
it('should add elements to a zone', function() {
var elements = { foo: { name: 'foo' } };
zone.elements = elements;
assert.equal(zone.elements.foo, elements.foo);
zone.elements.add({ name: 'bar' });
assert.equal(zone.elements.bar.name, 'bar');
});
});
describe('.elements#remove', function() {
it('should remove elements from a zone', function() {
var elements = { foo: { name: 'foo' } };
zone.elements = elements;
assert.equal(zone.elements.foo, elements.foo);
zone.elements.remove('foo');
assert.equal(zone.elements.foo, undefined);
});
});
describe('.elements.position', function() {
it('should modify the position of an element', function() {
zone.elements = {
foo: {
position: {
x: 100,
y: 200,
z: 300
}
}
};
assert.equal(zone.elements.foo.position.x, 100);
assert.equal(zone.elements.foo.position.y, 200);
assert.equal(zone.elements.foo.position.z, 300);
zone.elements.foo.position.x = -100;
zone.elements.foo.position.y = -200;
zone.elements.foo.position.z = -300;
assert.equal(zone.elements.foo.position.x, -100);
assert.equal(zone.elements.foo.position.y, -200);
assert.equal(zone.elements.foo.position.z, -300);
});
});
describe('.abc', function() {
it('should shift the location of a zone', function() {
});
});
describe('.elements.quadrant', function() {
it('should modify the quadrant of an element', function() {
});
});
});