|
|
@@ -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,
|