]> git.proxmox.com Git - extjs.git/blob - extjs/packages/core/test/specs/util/Region.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / core / test / specs / util / Region.js
1 Ext.require('Ext.util.Region', function() {
2 describe("Ext.util.Region", function() {
3 var region,
4 region1,
5 region2,
6 region3,
7 region4,
8 region5;
9
10 beforeEach(function() {
11 region1 = Ext.create('Ext.util.Region', 2, 5, 6, 1);
12 region2 = Ext.create('Ext.util.Region', 1, 6, 3, 4);
13 region3 = Ext.create('Ext.util.Region', 0, 2, 2, 0);
14 region4 = Ext.create('Ext.util.Region', 3, 4, 5, 2);
15 region5 = Ext.create('Ext.util.Region', 7, 3, 9, 1);
16 });
17
18 describe("contains", function() {
19 describe("form region 1 point of view", function() {
20 it("should not contain region 2", function() {
21 expect(region1.contains(region2)).toBe(false);
22 });
23
24 it("should not contain region 3", function() {
25 expect(region1.contains(region3)).toBe(false);
26 });
27
28 it("should contain region 4", function() {
29 expect(region1.contains(region4)).toBe(true);
30 });
31
32 it("should not contain region 5", function() {
33 expect(region1.contains(region5)).toBe(false);
34 });
35 });
36 });
37
38 describe("intersect", function() {
39 describe("form region 1 point of view", function() {
40 describe("between region 1 and 2", function() {
41 beforeEach(function() {
42 region = region1.intersect(region2);
43 });
44
45 it("should not return false", function() {
46 expect(region).not.toBe(false);
47 });
48
49 it("should return a region with top property equal to 2", function() {
50 expect(region.top).toEqual(2);
51 });
52
53 it("should return a region with left property equal to 4", function() {
54 expect(region.left).toEqual(4);
55 });
56
57 it("should return a region with bottom property equal to 3", function() {
58 expect(region.bottom).toEqual(3);
59 });
60
61 it("should return a region with right property equal to 5", function() {
62 expect(region.right).toEqual(5);
63 });
64 });
65
66 describe("between region 2 and 1", function() {
67 beforeEach(function() {
68 region = region2.intersect(region1);
69 });
70
71 it("should not return false", function() {
72 expect(region).not.toBe(false);
73 });
74
75 it("should return a region with top property equal to 2", function() {
76 expect(region.top).toEqual(2);
77 });
78
79 it("should return a region with left property equal to 4", function() {
80 expect(region.left).toEqual(4);
81 });
82
83 it("should return a region with bottom property equal to 3", function() {
84 expect(region.bottom).toEqual(3);
85 });
86
87 it("should return a region with right property equal to 5", function() {
88 expect(region.right).toEqual(5);
89 });
90 });
91
92 describe("between region 1 and 3", function() {
93 it("should have no intersection", function() {
94 expect(region1.intersect(region3)).toBe(false);
95 });
96 });
97
98 describe("between region 3 and 1", function() {
99 it("should have no intersection1", function() {
100 expect(region3.intersect(region1)).toBe(false);
101 });
102 });
103
104 describe("between region 1 and 4", function() {
105 beforeEach(function() {
106 region = region1.intersect(region4);
107 });
108
109 it("should not return false", function() {
110 expect(region).not.toBe(false);
111 });
112
113 it("should return a region with top property equal to 3", function() {
114 expect(region.top).toEqual(3);
115 });
116
117 it("should return a region with left property equal to 2", function() {
118 expect(region.left).toEqual(2);
119 });
120
121 it("should return a region with bottom property equal to 5", function() {
122 expect(region.bottom).toEqual(5);
123 });
124
125 it("should return a region with right property equal to 4", function() {
126 expect(region.right).toEqual(4);
127 });
128 });
129
130 describe("between region 4 and 1", function() {
131 beforeEach(function() {
132 region = region4.intersect(region1);
133 });
134
135 it("should not return false", function() {
136 expect(region).not.toBe(false);
137 });
138
139 it("should return a region with top property equal to 3", function() {
140 expect(region.top).toEqual(3);
141 });
142
143 it("should return a region with left property equal to 2", function() {
144 expect(region.left).toEqual(2);
145 });
146
147 it("should return a region with bottom property equal to 5", function() {
148 expect(region.bottom).toEqual(5);
149 });
150
151 it("should return a region with right property equal to 4", function() {
152 expect(region.right).toEqual(4);
153 });
154 });
155
156 describe("between region 1 and 5", function() {
157 it("should have no intersection", function() {
158 expect(region1.intersect(region5)).toBe(false);
159 });
160 });
161
162 describe("between region 5 and 1", function() {
163 it("should have no intersection", function() {
164 expect(region5.intersect(region1)).toBe(false);
165 });
166 });
167 });
168 });
169
170 describe("union", function() {
171 describe("form region 1 point of view", function() {
172 describe("between region 1 and 2", function() {
173 beforeEach(function() {
174 region = region1.union(region2);
175 });
176
177 it("should return a region with top property equal to 1", function() {
178 expect(region.top).toEqual(1);
179 });
180
181 it("should return a region with left property equal to 1", function() {
182 expect(region.left).toEqual(1);
183 });
184
185 it("should return a region with bottom property equal to 6", function() {
186 expect(region.bottom).toEqual(6);
187 });
188
189 it("should return a region with right property equal to 6", function() {
190 expect(region.right).toEqual(6);
191 });
192 });
193
194 describe("between region 2 and 1", function() {
195 beforeEach(function() {
196 region = region2.union(region1);
197 });
198
199 it("should return a region with top property equal to 1", function() {
200 expect(region.top).toEqual(1);
201 });
202
203 it("should return a region with left property equal to 1", function() {
204 expect(region.left).toEqual(1);
205 });
206
207 it("should return a region with bottom property equal to 6", function() {
208 expect(region.bottom).toEqual(6);
209 });
210
211 it("should return a region with right property equal to 6", function() {
212 expect(region.right).toEqual(6);
213 });
214 });
215
216 describe("between region 1 and 3", function() {
217 beforeEach(function() {
218 region = region1.union(region3);
219 });
220
221 it("should return a region with top property equal to 0", function() {
222 expect(region.top).toEqual(0);
223 });
224
225 it("should return a region with left property equal to 0", function() {
226 expect(region.left).toEqual(0);
227 });
228
229 it("should return a region with bottom property equal to 6", function() {
230 expect(region.bottom).toEqual(6);
231 });
232
233 it("should return a region with right property equal to 5", function() {
234 expect(region.right).toEqual(5);
235 });
236 });
237
238 describe("between region 3 and 1", function() {
239 beforeEach(function() {
240 region = region3.union(region1);
241 });
242
243 it("should return a region with top property equal to 0", function() {
244 expect(region.top).toEqual(0);
245 });
246
247 it("should return a region with left property equal to 0", function() {
248 expect(region.left).toEqual(0);
249 });
250
251 it("should return a region with bottom property equal to 6", function() {
252 expect(region.bottom).toEqual(6);
253 });
254
255 it("should return a region with right property equal to 5", function() {
256 expect(region.right).toEqual(5);
257 });
258 });
259
260 describe("between region 1 and 4", function() {
261 beforeEach(function() {
262 region = region1.union(region4);
263 });
264
265 it("should return a region with top property equal to 2", function() {
266 expect(region.top).toEqual(2);
267 });
268
269 it("should return a region with left property equal to 1", function() {
270 expect(region.left).toEqual(1);
271 });
272
273 it("should return a region with bottom property equal to 6", function() {
274 expect(region.bottom).toEqual(6);
275 });
276
277 it("should return a region with right property equal to 5", function() {
278 expect(region.right).toEqual(5);
279 });
280 });
281
282 describe("between region 4 and 1", function() {
283 beforeEach(function() {
284 region = region4.union(region1);
285 });
286
287 it("should return a region with top property equal to 2", function() {
288 expect(region.top).toEqual(2);
289 });
290
291 it("should return a region with left property equal to 1", function() {
292 expect(region.left).toEqual(1);
293 });
294
295 it("should return a region with bottom property equal to 6", function() {
296 expect(region.bottom).toEqual(6);
297 });
298
299 it("should return a region with right property equal to 5", function() {
300 expect(region.right).toEqual(5);
301 });
302 });
303
304 describe("between region 1 and 5", function() {
305 beforeEach(function() {
306 region = region1.union(region5);
307 });
308
309 it("should return a region with top property equal to 2", function() {
310 expect(region.top).toEqual(2);
311 });
312
313 it("should return a region with left property equal to 1", function() {
314 expect(region.left).toEqual(1);
315 });
316
317 it("should return a region with bottom property equal to 9", function() {
318 expect(region.bottom).toEqual(9);
319 });
320
321 it("should return a region with right property equal to 5", function() {
322 expect(region.right).toEqual(5);
323 });
324 });
325
326 describe("between region 5 and 1", function() {
327 beforeEach(function() {
328 region = region5.union(region1);
329 });
330
331 it("should return a region with top property equal to 2", function() {
332 expect(region.top).toEqual(2);
333 });
334
335 it("should return a region with left property equal to 1", function() {
336 expect(region.left).toEqual(1);
337 });
338
339 it("should return a region with bottom property equal to 9", function() {
340 expect(region.bottom).toEqual(9);
341 });
342
343 it("should return a region with right property equal to 5", function() {
344 expect(region.right).toEqual(5);
345 });
346 });
347 });
348 });
349
350 describe("constrainTo", function() {
351 describe("form region 1 point of view", function() {
352 describe("between region 1 and 2", function() {
353 beforeEach(function() {
354 region1.constrainTo(region2);
355 });
356
357 it("should set region 1 top property equal to 2", function() {
358 expect(region1.top).toEqual(2);
359 });
360
361 it("should set region 1 left property equal to 4", function() {
362 expect(region1.left).toEqual(4);
363 });
364
365 it("should set region 1 bottom property equal to 3", function() {
366 expect(region1.bottom).toEqual(3);
367 });
368
369 it("should set region 1 right property equal to 5", function() {
370 expect(region1.right).toEqual(5);
371 });
372 });
373
374 describe("between region 1 and 3", function() {
375 beforeEach(function() {
376 region1.constrainTo(region3);
377 });
378
379 it("should set region 1 top property equal to 2", function() {
380 expect(region1.top).toEqual(2);
381 });
382
383 it("should set region 1 left property equal to 1", function() {
384 expect(region1.left).toEqual(1);
385 });
386
387 it("should set region 1 bottom property equal to 2", function() {
388 expect(region1.bottom).toEqual(2);
389 });
390
391 it("should set region 1 right property equal to 2", function() {
392 expect(region1.right).toEqual(2);
393 });
394 });
395
396 describe("between region 1 and 4", function() {
397 beforeEach(function() {
398 region1.constrainTo(region4);
399 });
400
401 it("should set region 1 top property equal to 3", function() {
402 expect(region1.top).toEqual(3);
403 });
404
405 it("should set region 1 left property equal to 2", function() {
406 expect(region1.left).toEqual(2);
407 });
408
409 it("should set region 1 bottom property equal to 5", function() {
410 expect(region1.bottom).toEqual(5);
411 });
412
413 it("should set region 1 right property equal to 4", function() {
414 expect(region1.right).toEqual(4);
415 });
416 });
417
418 describe("between region 1 and 5", function() {
419 beforeEach(function() {
420 region1.constrainTo(region5);
421 });
422
423 it("should set region 1 top property equal to 7", function() {
424 expect(region1.top).toEqual(7);
425 });
426
427 it("should set region 1 left property equal to 1", function() {
428 expect(region1.left).toEqual(1);
429 });
430
431 it("should set region 1 bottom property equal to 7", function() {
432 expect(region1.bottom).toEqual(7);
433 });
434
435 it("should set region 1 right property equal to 3", function() {
436 expect(region1.right).toEqual(3);
437 });
438 });
439 });
440 });
441
442 describe("adjust", function() {
443 describe("modify the current region to be adjusted by offset", function() {
444 beforeEach(function() {
445 region1.adjust(1, 2, 3, 4);
446 });
447
448 it("should set region 1 top property equal to 3", function() {
449 expect(region1.top).toEqual(3);
450 });
451
452 it("should set region 1 left property equal to 5", function() {
453 expect(region1.left).toEqual(5);
454 });
455
456 it("should set region 1 bottom property equal to 9", function() {
457 expect(region1.bottom).toEqual(9);
458 });
459
460 it("should set region 1 right property equal to 7", function() {
461 expect(region1.right).toEqual(7);
462 });
463 });
464 });
465 });
466
467 });