Files
jasmine/src/core/asymmetric_equality/ArrayWithExactContents.js
2022-06-09 20:00:23 -07:00

37 lines
846 B
JavaScript

getJasmineRequireObj().ArrayWithExactContents = function(j$) {
function ArrayWithExactContents(sample) {
this.sample = sample;
}
ArrayWithExactContents.prototype.asymmetricMatch = function(
other,
matchersUtil
) {
if (!j$.isArray_(this.sample)) {
throw new Error(
'You must provide an array to arrayWithExactContents, not ' +
j$.basicPrettyPrinter_(this.sample) +
'.'
);
}
if (this.sample.length !== other.length) {
return false;
}
for (const item of this.sample) {
if (!matchersUtil.contains(other, item)) {
return false;
}
}
return true;
};
ArrayWithExactContents.prototype.jasmineToString = function(pp) {
return '<jasmine.arrayWithExactContents(' + pp(this.sample) + ')>';
};
return ArrayWithExactContents;
};