Merge branch 'jonahd-g-main'
* Adds jasmine.allOf asymmetric equality tester * Merges #2087 from @jonahd-g * Fixes #2083
This commit is contained in:
@@ -59,6 +59,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
|
||||
j$.util = jRequire.util(j$);
|
||||
j$.errors = jRequire.errors();
|
||||
j$.formatErrorMsg = jRequire.formatErrorMsg();
|
||||
j$.AllOf = jRequire.AllOf(j$);
|
||||
j$.Any = jRequire.Any(j$);
|
||||
j$.Anything = jRequire.Anything(j$);
|
||||
j$.CallTracker = jRequire.CallTracker(j$);
|
||||
@@ -416,6 +417,19 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get an {@link AsymmetricEqualityTester} that will succeed if the actual
|
||||
* value being compared matches every provided equality tester.
|
||||
* @name asymmetricEqualityTesters.allOf
|
||||
* @emittedName jasmine.allOf
|
||||
* @since 5.13.0
|
||||
* @function
|
||||
* @param {...*} arguments - The asymmetric equality checkers to compare.
|
||||
*/
|
||||
j$.allOf = function() {
|
||||
return new j$.AllOf(...arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get an {@link AsymmetricEqualityTester} that will succeed if the actual
|
||||
* value being compared is an instance of the specified class/constructor.
|
||||
@@ -2084,6 +2098,34 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
|
||||
return JsApiReporter;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().AllOf = function(j$) {
|
||||
function AllOf() {
|
||||
const expectedValues = Array.from(arguments);
|
||||
if (expectedValues.length === 0) {
|
||||
throw new TypeError(
|
||||
'jasmine.allOf() expects at least one argument to be passed.'
|
||||
);
|
||||
}
|
||||
this.expectedValues = expectedValues;
|
||||
}
|
||||
|
||||
AllOf.prototype.asymmetricMatch = function(other, matchersUtil) {
|
||||
for (const expectedValue of this.expectedValues) {
|
||||
if (!matchersUtil.equals(other, expectedValue)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
AllOf.prototype.jasmineToString = function(pp) {
|
||||
return '<jasmine.allOf(' + pp(this.expectedValues) + ')>';
|
||||
};
|
||||
|
||||
return AllOf;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().Any = function(j$) {
|
||||
function Any(expectedObject) {
|
||||
if (typeof expectedObject === 'undefined') {
|
||||
|
||||
Reference in New Issue
Block a user