diff --git a/build/karma.conf.js b/build/karma.conf.js index 417c295..fcb90a8 100644 --- a/build/karma.conf.js +++ b/build/karma.conf.js @@ -22,6 +22,7 @@ module.exports = function(config) { '../lib/moment/moment.js', '../lib/jquery/dist/jquery.js', + '../lib/jquery-ui/jquery-ui.js', // for jquery simulate '../lib/jquery-simulate-ext/libs/bililiteRange.js', diff --git a/tests/lib/jasmine-ext.js b/tests/lib/jasmine-ext.js index ab861cf..e2e24de 100644 --- a/tests/lib/jasmine-ext.js +++ b/tests/lib/jasmine-ext.js @@ -65,7 +65,8 @@ beforeEach(function() { var outer = getBounds(expected); var inner = getBounds(actual); var result = { - pass: inner.left >= outer.left && + pass: outer && inner && + inner.left >= outer.left && inner.right <= outer.right && inner.top >= outer.top && inner.bottom <= outer.bottom @@ -76,6 +77,38 @@ beforeEach(function() { return result; } }; + }, + toBeLeftOf: function() { + return { + compare: function(actual, expected) { + var subjectBounds = getBounds(actual); + var otherBounds = getBounds(expected); + var result = { + pass: subjectBounds && otherBounds && + subjectBounds.right <= otherBounds.left + }; + if (!result.pass) { + result.message = 'Element is not to the left of the other element'; + } + return result; + } + }; + }, + toBeRightOf: function() { + return { + compare: function(actual, expected) { + var subjectBounds = getBounds(actual); + var otherBounds = getBounds(expected); + var result = { + pass: subjectBounds && otherBounds && + subjectBounds.left >= otherBounds.right + }; + if (!result.pass) { + result.message = 'Element is not to the right of the other element'; + } + return result; + } + }; } }); @@ -97,6 +130,10 @@ beforeEach(function() { var el = $(node); var offset = el.offset(); + if (!offset) { + return false; + } + return { top: offset.top, left: offset.left,