Run cleanup

This commit is contained in:
Nito Buendia
2022-03-17 21:09:14 +08:00
parent e470fb56d7
commit c5db939886
2 changed files with 11 additions and 8 deletions

View File

@@ -38,7 +38,7 @@ describe('toHaveSpyInteractions', function() {
); );
}); });
it('shows the right message is negated', function () { it('shows the right message is negated', function() {
let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions();
let spyObj = jasmineUnderTest let spyObj = jasmineUnderTest
.getEnv() .getEnv()
@@ -48,7 +48,8 @@ describe('toHaveSpyInteractions', function() {
let result = matcher.compare(spyObj); let result = matcher.compare(spyObj);
expect(result.pass).toBe(true); expect(result.pass).toBe(true);
expect(result.message).toContain( // Will be shown only on negate. expect(result.message).toContain(
// Will be shown only on negate.
'Expected spy object spies not to have been called' 'Expected spy object spies not to have been called'
); );
}); });
@@ -76,11 +77,11 @@ describe('toHaveSpyInteractions', function() {
matcher.compare(true); matcher.compare(true);
}).toThrowError(Error, /Expected a spy object, but got/); }).toThrowError(Error, /Expected a spy object, but got/);
expect(function () { expect(function() {
matcher.compare(123); matcher.compare(123);
}).toThrowError(Error, /Expected a spy object, but got/); }).toThrowError(Error, /Expected a spy object, but got/);
expect(function () { expect(function() {
matcher.compare('string'); matcher.compare('string');
}).toThrowError(Error, /Expected a spy object, but got/); }).toThrowError(Error, /Expected a spy object, but got/);
}); });

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().toHaveSpyInteractions = function (j$) { getJasmineRequireObj().toHaveSpyInteractions = function(j$) {
var getErrorMsg = j$.formatErrorMsg( var getErrorMsg = j$.formatErrorMsg(
'<toHaveSpyInteractions>', '<toHaveSpyInteractions>',
'expect(<spyObj>).toHaveSpyInteractions()' 'expect(<spyObj>).toHaveSpyInteractions()'
@@ -14,7 +14,7 @@ getJasmineRequireObj().toHaveSpyInteractions = function (j$) {
*/ */
function toHaveSpyInteractions(matchersUtil) { function toHaveSpyInteractions(matchersUtil) {
return { return {
compare: function (actual) { compare: function(actual) {
var result = {}; var result = {};
if (!j$.isObject_(actual)) { if (!j$.isObject_(actual)) {
@@ -53,9 +53,11 @@ getJasmineRequireObj().toHaveSpyInteractions = function (j$) {
resultMessage = resultMessage =
'Expected spy object spies not to have been called, ' + 'Expected spy object spies not to have been called, ' +
'but the following spies were called: '; 'but the following spies were called: ';
resultMessage += calledSpies.map(([spyName, spyCount]) => { resultMessage += calledSpies
.map(([spyName, spyCount]) => {
return `${spyName} called ${spyCount} time(s)`; return `${spyName} called ${spyCount} time(s)`;
}).join(', '); })
.join(', ');
} else { } else {
resultMessage = resultMessage =
'Expected spy object spies to have been called, ' + 'Expected spy object spies to have been called, ' +