-
Notifications
You must be signed in to change notification settings - Fork 228
/
prefer-called-with.js
44 lines (40 loc) · 1.06 KB
/
prefer-called-with.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
'use strict';
const { RuleTester } = require('eslint');
const rule = require('../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);',
],
invalid: [
{
code: 'expect(fn).toBeCalled();',
errors: [
{
message: 'Prefer toBeCalledWith(/* expected args */)',
column: 12,
line: 1,
},
],
},
{
code: 'expect(fn).toHaveBeenCalled();',
errors: [
{
message: 'Prefer toHaveBeenCalledWith(/* expected args */)',
column: 12,
line: 1,
},
],
},
],
});