/
prefer-called-with.test.js
45 lines (42 loc) · 1.08 KB
/
prefer-called-with.test.js
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
import { RuleTester } from 'eslint';
import rule from '../prefer-called-with';
const ruleTester = new 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).not.toHaveBeenCalled();',
'expect(fn).not.toBeCalledWith();',
'expect(fn).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).toHaveBeenCalled();',
errors: [
{
messageId: 'preferCalledWith',
data: { name: 'toHaveBeenCalled' },
column: 12,
line: 1,
},
],
},
],
});