Files
jasmine/src/core/asymmetric_equality/StringContaining.js
2021-09-22 11:28:24 -07:00

25 lines
637 B
JavaScript

getJasmineRequireObj().StringContaining = function(j$) {
function StringContaining(expected) {
if (!j$.isString_(expected)) {
throw new Error('Expected is not a String');
}
this.expected = expected;
}
StringContaining.prototype.asymmetricMatch = function(other) {
if (!j$.isString_(other)) {
// Arrays, etc. don't match no matter what their indexOf returns.
return false;
}
return other.indexOf(this.expected) !== -1;
};
StringContaining.prototype.jasmineToString = function() {
return '<jasmine.stringContaining("' + this.expected + '")>';
};
return StringContaining;
};