Refactor Suite#addExpectationResult to use named arguments

This commit is contained in:
Steve Gravrock
2025-09-21 09:05:00 -07:00
parent 4a36ece65b
commit 4020da25a4
2 changed files with 36 additions and 38 deletions

View File

@@ -10742,9 +10742,13 @@ getJasmineRequireObj().Suite = function(j$) {
this.onLateError(new Error(msg)); this.onLateError(new Error(msg));
} }
addExpectationResult() { addExpectationResult(passed, data) {
if (isFailure(arguments)) { if (passed) {
const data = arguments[1]; // Passed expectations are accepted for compatibility with
// Spec#addExpectationResult, but aren't recorded.
return;
}
const expectationResult = j$.buildExpectationResult(data); const expectationResult = j$.buildExpectationResult(data);
if (this.reportedDone) { if (this.reportedDone) {
@@ -10762,7 +10766,6 @@ getJasmineRequireObj().Suite = function(j$) {
throw new j$.errors.ExpectationFailed(); throw new j$.errors.ExpectationFailed();
} }
} }
}
addDeprecationWarning(deprecation) { addDeprecationWarning(deprecation) {
if (typeof deprecation === 'string') { if (typeof deprecation === 'string') {
@@ -10857,10 +10860,6 @@ getJasmineRequireObj().Suite = function(j$) {
} }
} }
function isFailure(args) {
return !args[0];
}
return Suite; return Suite;
}; };

View File

@@ -220,9 +220,13 @@ getJasmineRequireObj().Suite = function(j$) {
this.onLateError(new Error(msg)); this.onLateError(new Error(msg));
} }
addExpectationResult() { addExpectationResult(passed, data) {
if (isFailure(arguments)) { if (passed) {
const data = arguments[1]; // Passed expectations are accepted for compatibility with
// Spec#addExpectationResult, but aren't recorded.
return;
}
const expectationResult = j$.buildExpectationResult(data); const expectationResult = j$.buildExpectationResult(data);
if (this.reportedDone) { if (this.reportedDone) {
@@ -240,7 +244,6 @@ getJasmineRequireObj().Suite = function(j$) {
throw new j$.errors.ExpectationFailed(); throw new j$.errors.ExpectationFailed();
} }
} }
}
addDeprecationWarning(deprecation) { addDeprecationWarning(deprecation) {
if (typeof deprecation === 'string') { if (typeof deprecation === 'string') {
@@ -335,9 +338,5 @@ getJasmineRequireObj().Suite = function(j$) {
} }
} }
function isFailure(args) {
return !args[0];
}
return Suite; return Suite;
}; };