Skip to content

Commit

Permalink
fix: Print callback syntax in expectation error message
Browse files Browse the repository at this point in the history
  • Loading branch information
NiGhTTraX committed Jul 28, 2022
1 parent 5e847d9 commit 0bf9633
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/errors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('errors', () => {

expectAnsilessEqual(
pendingExpectation.toJSON(),
`when(mock.bar(1, 2, 3))`
`when(() => mock.bar(1, 2, 3))`
);
});

Expand All @@ -48,7 +48,7 @@ describe('errors', () => {
pendingExpectation.args = undefined;
pendingExpectation.property = 'bar';

expectAnsilessEqual(pendingExpectation.toJSON(), `when(mock.bar)`);
expectAnsilessEqual(pendingExpectation.toJSON(), `when(() => mock.bar)`);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/expectation/strong-expectation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('StrongExpectation', () => {

expectAnsilessEqual(
expectation.toJSON(),
`when(mock.baz(4, 5, 6)).thenReturn(42).between(2, 3)`
`when(() => mock.baz(4, 5, 6)).thenReturn(42).between(2, 3)`
);
});

Expand Down
4 changes: 2 additions & 2 deletions src/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ export const printReturns = (

export const printWhen = (property: Property, args: any[] | undefined) => {
if (args) {
return `when(${EXPECTED_COLOR(`mock${printCall(property, args)}`)})`;
return `when(() => ${EXPECTED_COLOR(`mock${printCall(property, args)}`)})`;
}

return `when(${EXPECTED_COLOR(`mock${printProperty(property)}`)})`;
return `when(() => ${EXPECTED_COLOR(`mock${printProperty(property)}`)})`;
};

export const printExpectation = (
Expand Down

0 comments on commit 0bf9633

Please sign in to comment.