Skip to content

Commit cddbf07

Browse files
committed
cover Utils.isIntercepted
1 parent 9168a7f commit cddbf07

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

spec/utils-spec.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,23 @@ describe('gridstack utils', function() {
3939

4040
});
4141

42+
describe('test isIntercepted', function() {
43+
var src = {x: 3, y: 2, width: 3, height: 2};
44+
45+
it('should intercept.', function() {
46+
expect(utils.isIntercepted(src, {x: 0, y: 0, width: 4, height: 3})).toEqual(true);
47+
expect(utils.isIntercepted(src, {x: 0, y: 0, width: 40, height: 30})).toEqual(true);
48+
expect(utils.isIntercepted(src, {x: 3, y: 2, width: 3, height: 2})).toEqual(true);
49+
expect(utils.isIntercepted(src, {x: 5, y: 3, width: 3, height: 2})).toEqual(true);
50+
});
51+
52+
it('shouldn\'t intercept.', function() {
53+
expect(utils.isIntercepted(src, {x: 0, y: 0, width: 3, height: 2})).toEqual(false);
54+
expect(utils.isIntercepted(src, {x: 0, y: 0, width: 13, height: 2})).toEqual(false);
55+
expect(utils.isIntercepted(src, {x: 1, y: 4, width: 13, height: 2})).toEqual(false);
56+
expect(utils.isIntercepted(src, {x: 0, y: 3, width: 3, height: 2})).toEqual(false);
57+
expect(utils.isIntercepted(src, {x: 6, y: 3, width: 3, height: 2})).toEqual(false);
58+
});
59+
});
4260

43-
});
61+
});

0 commit comments

Comments
 (0)