From cddbf077be7620f379d79d8de953604416970107 Mon Sep 17 00:00:00 2001 From: Pavel Reznikov Date: Mon, 22 Feb 2016 18:59:32 -0800 Subject: [PATCH] cover Utils.isIntercepted --- spec/utils-spec.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/spec/utils-spec.js b/spec/utils-spec.js index 45b17dc31..36af16ca3 100644 --- a/spec/utils-spec.js +++ b/spec/utils-spec.js @@ -39,5 +39,23 @@ describe('gridstack utils', function() { }); + describe('test isIntercepted', function() { + var src = {x: 3, y: 2, width: 3, height: 2}; + + it('should intercept.', function() { + expect(utils.isIntercepted(src, {x: 0, y: 0, width: 4, height: 3})).toEqual(true); + expect(utils.isIntercepted(src, {x: 0, y: 0, width: 40, height: 30})).toEqual(true); + expect(utils.isIntercepted(src, {x: 3, y: 2, width: 3, height: 2})).toEqual(true); + expect(utils.isIntercepted(src, {x: 5, y: 3, width: 3, height: 2})).toEqual(true); + }); + + it('shouldn\'t intercept.', function() { + expect(utils.isIntercepted(src, {x: 0, y: 0, width: 3, height: 2})).toEqual(false); + expect(utils.isIntercepted(src, {x: 0, y: 0, width: 13, height: 2})).toEqual(false); + expect(utils.isIntercepted(src, {x: 1, y: 4, width: 13, height: 2})).toEqual(false); + expect(utils.isIntercepted(src, {x: 0, y: 3, width: 3, height: 2})).toEqual(false); + expect(utils.isIntercepted(src, {x: 6, y: 3, width: 3, height: 2})).toEqual(false); + }); + }); -}); \ No newline at end of file +});