/
prefer-todo.test.ts
53 lines (51 loc) · 1.5 KB
/
prefer-todo.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
import { TSESLint } from '@typescript-eslint/experimental-utils';
import rule from '../prefer-todo';
const ruleTester = new TSESLint.RuleTester({
parserOptions: { ecmaVersion: 2015 },
});
ruleTester.run('prefer-todo', rule, {
valid: [
'test.todo("i need to write this test");',
'test(obj)',
'fit("foo")',
'xit("foo")',
'test("stub", () => expect(1).toBe(1));',
`
supportsDone && params.length < test.length
? done => test(...params, done)
: () => test(...params);
`,
],
invalid: [
{
code: `test("i need to write this test");`,
errors: [{ messageId: 'todoOverUnimplemented' }],
output: 'test.todo("i need to write this test");',
},
{
code: 'test(`i need to write this test`);',
errors: [{ messageId: 'todoOverUnimplemented' }],
output: 'test.todo(`i need to write this test`);',
},
{
code: 'it("foo", function () {})',
errors: [{ messageId: 'todoOverEmpty' }],
output: 'it.todo("foo")',
},
{
code: 'it("foo", () => {})',
errors: [{ messageId: 'todoOverEmpty' }],
output: 'it.todo("foo")',
},
{
code: `test.skip("i need to write this test", () => {});`,
errors: [{ messageId: 'todoOverEmpty' }],
output: 'test.todo("i need to write this test");',
},
{
code: `test.skip("i need to write this test", function() {});`,
errors: [{ messageId: 'todoOverEmpty' }],
output: 'test.todo("i need to write this test");',
},
],
});