Files
edx-platform/lms/static/js/spec/edxnotes/custom_matchers.js
polesye c7153be040 TNL-213: Let Students Add Personal Notes to Course Content.
Co-Authored-By: Jean-Michel Claus <jmc@edx.org>
Co-Authored-By: Brian Talbot <btalbot@edx.org>
Co-Authored-By: Tim Babych <tim@edx.org>
Co-Authored-By: Oleg Marshev <oleg@edx.org>
Co-Authored-By: Chris Rodriguez <crodriguez@edx.org>
2015-01-14 23:34:11 +02:00

33 lines
978 B
JavaScript

define(['jquery'], function($) {
'use strict';
return function (that) {
that.addMatchers({
toContainText: function (text) {
var trimmedText = $.trim($(this.actual).text());
if (text && $.isFunction(text.test)) {
return text.test(trimmedText);
} else {
return trimmedText.indexOf(text) !== -1;
}
},
toHaveLength: function (number) {
return $(this.actual).length === number;
},
toHaveIndex: function (number) {
return $(this.actual).index() === number;
},
toBeInRange: function (min, max) {
return min <= this.actual && this.actual <= max;
},
toBeFocused: function () {
return $(this.actual)[0] === $(this.actual)[0].ownerDocument.activeElement;
}
});
};
});