-
Notifications
You must be signed in to change notification settings - Fork 240
/
Copy pathprefer-called-with.test.ts
58 lines (55 loc) · 1.43 KB
/
prefer-called-with.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { TSESLint } from '@typescript-eslint/utils';
import rule from '../prefer-called-with';
const ruleTester = new TSESLint.RuleTester();
ruleTester.run('prefer-called-with', rule, {
valid: [
'expect(fn).toBeCalledWith();',
'expect(fn).toHaveBeenCalledWith();',
'expect(fn).toBeCalledWith(expect.anything());',
'expect(fn).toHaveBeenCalledWith(expect.anything());',
'expect(fn).not.toBeCalled();',
'expect(fn).rejects.not.toBeCalled();',
'expect(fn).not.toHaveBeenCalled();',
'expect(fn).not.toBeCalledWith();',
'expect(fn).not.toHaveBeenCalledWith();',
'expect(fn).resolves.not.toHaveBeenCalledWith();',
'expect(fn).toBeCalledTimes(0);',
'expect(fn).toHaveBeenCalledTimes(0);',
'expect(fn);',
],
invalid: [
{
code: 'expect(fn).toBeCalled();',
errors: [
{
messageId: 'preferCalledWith',
data: { name: 'toBeCalled' },
column: 12,
line: 1,
},
],
},
{
code: 'expect(fn).resolves.toBeCalled();',
errors: [
{
messageId: 'preferCalledWith',
data: { name: 'toBeCalled' },
column: 21,
line: 1,
},
],
},
{
code: 'expect(fn).toHaveBeenCalled();',
errors: [
{
messageId: 'preferCalledWith',
data: { name: 'toHaveBeenCalled' },
column: 12,
line: 1,
},
],
},
],
});