The old style of merging all of a function's variable declarations into a single statement made some sense back in the days of var, but there's no reason to keep doing it now that we use const and let.
56 lines
1.8 KiB
JavaScript
56 lines
1.8 KiB
JavaScript
(function() {
|
|
specHelpers.registerIntegrationMatchers = function() {
|
|
jasmine.addMatchers({
|
|
toHaveFailedExpectationsForRunnable: function() {
|
|
return {
|
|
compare: function(actual, fullName, expectedFailures) {
|
|
let foundRunnable = false;
|
|
let expectations = true;
|
|
let foundFailures = [];
|
|
|
|
for (let i = 0; i < actual.calls.count(); i++) {
|
|
const args = actual.calls.argsFor(i)[0];
|
|
|
|
if (args.fullName === fullName) {
|
|
foundRunnable = true;
|
|
|
|
for (let j = 0; j < args.failedExpectations.length; j++) {
|
|
foundFailures.push(args.failedExpectations[j].message);
|
|
}
|
|
|
|
for (let j = 0; j < expectedFailures.length; j++) {
|
|
const failure = foundFailures[j];
|
|
const expectedFailure = expectedFailures[j];
|
|
|
|
if (
|
|
Object.prototype.toString.call(expectedFailure) ===
|
|
'[object RegExp]'
|
|
) {
|
|
expectations =
|
|
expectations && expectedFailure.test(failure);
|
|
} else {
|
|
expectations = expectations && failure === expectedFailure;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
return {
|
|
pass: foundRunnable && expectations,
|
|
message: !foundRunnable
|
|
? 'The runnable "' + fullName + '" never finished'
|
|
: 'Expected runnable "' +
|
|
fullName +
|
|
'" to have failures ' +
|
|
jasmine.private.basicPrettyPrinter(expectedFailures) +
|
|
' but it had ' +
|
|
jasmine.private.basicPrettyPrinter(foundFailures)
|
|
};
|
|
}
|
|
};
|
|
}
|
|
});
|
|
};
|
|
})();
|