|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const { RuleTester } = require('eslint'); |
| 4 | +const rule = require('../no-empty-title'); |
| 5 | + |
| 6 | +const ruleTester = new RuleTester({ |
| 7 | + parserOptions: { |
| 8 | + sourceType: 'module', |
| 9 | + }, |
| 10 | +}); |
| 11 | + |
| 12 | +ruleTester.run('no-empty-title', rule, { |
| 13 | + valid: [ |
| 14 | + 'someFn("", function () {})', |
| 15 | + 'describe(1, function () {})', |
| 16 | + 'describe("foo", function () {})', |
| 17 | + 'describe("foo", function () { it("bar", function () {}) })', |
| 18 | + 'test("foo", function () {})', |
| 19 | + 'test(`foo`, function () {})', |
| 20 | + 'test(`${foo}`, function () {})', |
| 21 | + "it('foo', function () {})", |
| 22 | + "xdescribe('foo', function () {})", |
| 23 | + "xit('foo', function () {})", |
| 24 | + "xtest('foo', function () {})", |
| 25 | + ], |
| 26 | + invalid: [ |
| 27 | + { |
| 28 | + code: 'describe("", function () {})', |
| 29 | + errors: [ |
| 30 | + { |
| 31 | + message: rule.errorMessages.describe, |
| 32 | + column: 1, |
| 33 | + line: 1, |
| 34 | + }, |
| 35 | + ], |
| 36 | + }, |
| 37 | + { |
| 38 | + code: ["describe('foo', () => {", "it('', () => {})", '})'].join('\n'), |
| 39 | + errors: [ |
| 40 | + { |
| 41 | + message: rule.errorMessages.test, |
| 42 | + column: 1, |
| 43 | + line: 2, |
| 44 | + }, |
| 45 | + ], |
| 46 | + }, |
| 47 | + { |
| 48 | + code: 'it("", function () {})', |
| 49 | + errors: [ |
| 50 | + { |
| 51 | + message: rule.errorMessages.test, |
| 52 | + column: 1, |
| 53 | + line: 1, |
| 54 | + }, |
| 55 | + ], |
| 56 | + }, |
| 57 | + { |
| 58 | + code: 'test("", function () {})', |
| 59 | + errors: [ |
| 60 | + { |
| 61 | + message: rule.errorMessages.test, |
| 62 | + column: 1, |
| 63 | + line: 1, |
| 64 | + }, |
| 65 | + ], |
| 66 | + }, |
| 67 | + { |
| 68 | + code: 'test(``, function () {})', |
| 69 | + errors: [ |
| 70 | + { |
| 71 | + message: rule.errorMessages.test, |
| 72 | + column: 1, |
| 73 | + line: 1, |
| 74 | + }, |
| 75 | + ], |
| 76 | + }, |
| 77 | + { |
| 78 | + code: "xdescribe('', () => {})", |
| 79 | + errors: [ |
| 80 | + { |
| 81 | + message: rule.errorMessages.describe, |
| 82 | + column: 1, |
| 83 | + line: 1, |
| 84 | + }, |
| 85 | + ], |
| 86 | + }, |
| 87 | + { |
| 88 | + code: "xit('', () => {})", |
| 89 | + errors: [ |
| 90 | + { |
| 91 | + message: rule.errorMessages.test, |
| 92 | + column: 1, |
| 93 | + line: 1, |
| 94 | + }, |
| 95 | + ], |
| 96 | + }, |
| 97 | + { |
| 98 | + code: "xtest('', () => {})", |
| 99 | + errors: [ |
| 100 | + { |
| 101 | + message: rule.errorMessages.test, |
| 102 | + column: 1, |
| 103 | + line: 1, |
| 104 | + }, |
| 105 | + ], |
| 106 | + }, |
| 107 | + ], |
| 108 | +}); |
0 commit comments