Skip to content

Commit

Permalink
fix(prefer-mock-promise-shorthand): ignore mockImplementation funct…
Browse files Browse the repository at this point in the history
…ions that have parameters (#1199)
  • Loading branch information
G-Rath authored Aug 19, 2022
1 parent 24e85c8 commit 78ccbef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/rules/__tests__/prefer-mock-promise-shorthand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ruleTester.run('prefer-mock-shorthand', rule, {
'aVariable.mockReturnValue(Promise.reject().then(() => 1))',
'aVariable.mockReturnValue(new Promise(resolve => resolve(1)))',
'aVariable.mockReturnValue(new Promise((_, reject) => reject(1)))',
"jest.spyOn(Thingy, 'method').mockImplementation(param => Promise.resolve(param));",
dedent`
aVariable.mockImplementation(() => {
const value = new Date();
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-mock-promise-shorthand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default createRule({
} else if (mockFnName === withOnce('mockImplementation', isOnce)) {
const [arg] = node.arguments;

if (!isFunction(arg)) {
if (!isFunction(arg) || arg.params.length !== 0) {
return;
}

Expand Down

0 comments on commit 78ccbef

Please sign in to comment.