|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const { RuleTester } = require('eslint'); |
| 4 | +const rule = require('../prefer-todo'); |
| 5 | + |
| 6 | +const ruleTester = new RuleTester({ |
| 7 | + parserOptions: { ecmaVersion: 2015 }, |
| 8 | +}); |
| 9 | + |
| 10 | +ruleTester.run('prefer-todo', rule, { |
| 11 | + valid: [ |
| 12 | + 'test.todo("i need to write this test");', |
| 13 | + 'test(obj)', |
| 14 | + 'fit("foo")', |
| 15 | + 'xit("foo")', |
| 16 | + 'test("stub", () => expect(1).toBe(1));', |
| 17 | + ` |
| 18 | + supportsDone && params.length < test.length |
| 19 | + ? done => test(...params, done) |
| 20 | + : () => test(...params); |
| 21 | + `, |
| 22 | + ], |
| 23 | + invalid: [ |
| 24 | + { |
| 25 | + code: `test("i need to write this test");`, |
| 26 | + errors: [ |
| 27 | + { message: 'Prefer todo test case over unimplemented test case' }, |
| 28 | + ], |
| 29 | + output: 'test.todo("i need to write this test");', |
| 30 | + }, |
| 31 | + { |
| 32 | + code: 'test(`i need to write this test`);', |
| 33 | + errors: [ |
| 34 | + { message: 'Prefer todo test case over unimplemented test case' }, |
| 35 | + ], |
| 36 | + output: 'test.todo(`i need to write this test`);', |
| 37 | + }, |
| 38 | + { |
| 39 | + code: 'it("foo", function () {})', |
| 40 | + errors: ['Prefer todo test case over empty test case'], |
| 41 | + output: 'it.todo("foo")', |
| 42 | + }, |
| 43 | + { |
| 44 | + code: 'it("foo", () => {})', |
| 45 | + errors: ['Prefer todo test case over empty test case'], |
| 46 | + output: 'it.todo("foo")', |
| 47 | + }, |
| 48 | + { |
| 49 | + code: `test.skip("i need to write this test", () => {});`, |
| 50 | + errors: ['Prefer todo test case over empty test case'], |
| 51 | + output: 'test.todo("i need to write this test");', |
| 52 | + }, |
| 53 | + { |
| 54 | + code: `test.skip("i need to write this test", function() {});`, |
| 55 | + errors: ['Prefer todo test case over empty test case'], |
| 56 | + output: 'test.todo("i need to write this test");', |
| 57 | + }, |
| 58 | + ], |
| 59 | +}); |
0 commit comments