Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
Co-authored-by: Tom Mrazauskas <[email protected]>
  • Loading branch information
royhadad and mrazauskas authored Sep 18, 2022
1 parent c87ad1c commit f2bfab9
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions packages/jest-types/__typetests__/expect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,26 @@ expectType<void>(expect(jest.fn()).toHaveBeenCalledWith(123));
expectType<void>(expect(jest.fn()).toHaveBeenCalledWith(123, 'value'));
expectType<void>(expect(jest.fn()).toHaveBeenCalledWith(123, 'value'));

// type inference for "CalledWith" matchers parameters
const jestFnWithParams = jest.fn((a: string, b: number) => {});
expectType<void>(expect(jestFnWithParams).toHaveBeenCalledWith('value', 123));
expectError(expect(jestFnWithParams).toHaveBeenCalledWith(123, 'value'));
expectType<void>(
expect(
jest.fn<(a: string, b: number, c?: boolean) => void>(),
).toHaveBeenCalledWith('value', 123),
);
expectType<void>(
expect(
jest.fn<(a: string, b: number, c?: boolean) => void>(),
).toHaveBeenCalledWith('value', 123, true),
);
expectError(
expect(
jest.fn<(a: string, b: number, c?: boolean) => void>(),
).toHaveBeenCalledWith(123, 'value'),
);
expectError(
expect(
jest.fn<(a: string, b: number, c?: boolean) => void>(),
).toHaveBeenCalledWith('value', 123, 'nope'),
);

expectType<void>(expect(jest.fn()).lastCalledWith());
expectType<void>(expect(jest.fn()).lastCalledWith('value'));
Expand Down

0 comments on commit f2bfab9

Please sign in to comment.