Merge branch 'arrayContaining' of https://github.com/slackersoft/jasmine into slackersoft-arrayContaining
Merge #440 [Finish #59947350]
This commit is contained in:
25
src/core/asymmetric_equality/ArrayContaining.js
Normal file
25
src/core/asymmetric_equality/ArrayContaining.js
Normal file
@@ -0,0 +1,25 @@
|
||||
getJasmineRequireObj().ArrayContaining = function(j$) {
|
||||
function ArrayContaining(sample) {
|
||||
this.sample = sample;
|
||||
}
|
||||
|
||||
ArrayContaining.prototype.asymmetricMatch = function(other) {
|
||||
var className = Object.prototype.toString.call(this.sample);
|
||||
if (className !== "[object Array]") { throw new Error("You must provide an array to arrayContaining, not '" + this.sample + "'."); }
|
||||
|
||||
for (var i = 0; i < this.sample.length; i++) {
|
||||
var item = this.sample[i];
|
||||
if (!j$.matchersUtil.contains(other, item)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
ArrayContaining.prototype.jasmineToString = function () {
|
||||
return "<jasmine.arrayContaining(" + jasmine.pp(this.sample) +")>";
|
||||
};
|
||||
|
||||
return ArrayContaining;
|
||||
};
|
||||
Reference in New Issue
Block a user