some additional automated test utilities

This commit is contained in:
Adam Shaw
2014-08-23 18:12:36 -07:00
parent aec778518e
commit b985235098
2 changed files with 39 additions and 1 deletions
+1
View File
@@ -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',
+38 -1
View File
@@ -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,