Added a stringContaining asymmetric equality tester

* Fixes #1923.
This commit is contained in:
Steve Gravrock
2021-09-22 11:19:59 -07:00
parent 00f6708e1f
commit e3c9a59c6c
6 changed files with 110 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
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;
};