UNPKG

1.13 kBJavaScriptView Raw
1describe('Region', function(){
2 var Region = require('../index')
3
4 it('should have correct width', function(){
5 var r = Region({
6 top: 10,
7 left: 20,
8 right: 40,
9 bottom: 20
10 })
11
12 r.getWidth()
13 .should
14 .equal(20)
15
16 })
17
18 it('should have correct height', function(){
19 var r = new Region({
20 top: 10,
21 left: 20,
22 width: 30,
23 height: 40
24 })
25
26 r.getBottom()
27 .should
28 .equal(50)
29 })
30
31 it('should return correct intersection', function(){
32 var r1 = Region({
33 top: 10,
34 left: 10,
35 right: 40,
36 bottom: 40
37 })
38
39 var r2 = Region({
40 top: 20,
41 left: 15,
42 right: 45,
43 bottom: 35
44 })
45
46 var intersection = r1.getIntersection(r2)
47
48 intersection.get()
49 .should
50 .eql({
51 top: 20,
52 left: 15,
53 right: 40,
54 bottom: 35
55 })
56 })
57})
\No newline at end of file