|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const RuleTester = require('eslint').RuleTester; |
| 4 | +const rules = require('../..').rules; |
| 5 | + |
| 6 | +const ruleTester = new RuleTester({ |
| 7 | + parserOptions: { |
| 8 | + ecmaVersion: 6, |
| 9 | + }, |
| 10 | +}); |
| 11 | + |
| 12 | +ruleTester.run('lowercase-name', rules['lowercase-name'], { |
| 13 | + valid: [ |
| 14 | + "it(' ', function () {})", |
| 15 | + 'it(" ", function () {})', |
| 16 | + 'it(` `, function () {})', |
| 17 | + "it('foo', function () {})", |
| 18 | + 'it("foo", function () {})', |
| 19 | + 'it(`foo`, function () {})', |
| 20 | + 'it("<Foo/>", function () {})', |
| 21 | + 'it("123 foo", function () {})', |
| 22 | + 'it(42, function () {})', |
| 23 | + "test('foo', function () {})", |
| 24 | + 'test("foo", function () {})', |
| 25 | + 'test(`foo`, function () {})', |
| 26 | + 'test("<Foo/>", function () {})', |
| 27 | + 'test("123 foo", function () {})', |
| 28 | + 'test("42", function () {})', |
| 29 | + "describe('foo', function () {})", |
| 30 | + 'describe("foo", function () {})', |
| 31 | + 'describe(`foo`, function () {})', |
| 32 | + 'describe("<Foo/>", function () {})', |
| 33 | + 'describe("123 foo", function () {})', |
| 34 | + 'describe("42", function () {})', |
| 35 | + 'describe(function () {})', |
| 36 | + ], |
| 37 | + |
| 38 | + invalid: [ |
| 39 | + { |
| 40 | + code: "it('Foo', function () {})", |
| 41 | + errors: [ |
| 42 | + { |
| 43 | + message: '`it`s should begin with lowercase', |
| 44 | + column: 1, |
| 45 | + line: 1, |
| 46 | + }, |
| 47 | + ], |
| 48 | + }, |
| 49 | + { |
| 50 | + code: 'it("Foo", function () {})', |
| 51 | + errors: [ |
| 52 | + { |
| 53 | + message: '`it`s should begin with lowercase', |
| 54 | + column: 1, |
| 55 | + line: 1, |
| 56 | + }, |
| 57 | + ], |
| 58 | + }, |
| 59 | + { |
| 60 | + code: 'it(`Foo`, function () {})', |
| 61 | + errors: [ |
| 62 | + { |
| 63 | + message: '`it`s should begin with lowercase', |
| 64 | + column: 1, |
| 65 | + line: 1, |
| 66 | + }, |
| 67 | + ], |
| 68 | + }, |
| 69 | + { |
| 70 | + code: "test('Foo', function () {})", |
| 71 | + errors: [ |
| 72 | + { |
| 73 | + message: '`test`s should begin with lowercase', |
| 74 | + column: 1, |
| 75 | + line: 1, |
| 76 | + }, |
| 77 | + ], |
| 78 | + }, |
| 79 | + { |
| 80 | + code: 'test("Foo", function () {})', |
| 81 | + errors: [ |
| 82 | + { |
| 83 | + message: '`test`s should begin with lowercase', |
| 84 | + column: 1, |
| 85 | + line: 1, |
| 86 | + }, |
| 87 | + ], |
| 88 | + }, |
| 89 | + { |
| 90 | + code: 'test(`Foo`, function () {})', |
| 91 | + errors: [ |
| 92 | + { |
| 93 | + message: '`test`s should begin with lowercase', |
| 94 | + column: 1, |
| 95 | + line: 1, |
| 96 | + }, |
| 97 | + ], |
| 98 | + }, |
| 99 | + { |
| 100 | + code: "describe('Foo', function () {})", |
| 101 | + errors: [ |
| 102 | + { |
| 103 | + message: '`describe`s should begin with lowercase', |
| 104 | + column: 1, |
| 105 | + line: 1, |
| 106 | + }, |
| 107 | + ], |
| 108 | + }, |
| 109 | + { |
| 110 | + code: 'describe("Foo", function () {})', |
| 111 | + errors: [ |
| 112 | + { |
| 113 | + message: '`describe`s should begin with lowercase', |
| 114 | + column: 1, |
| 115 | + line: 1, |
| 116 | + }, |
| 117 | + ], |
| 118 | + }, |
| 119 | + { |
| 120 | + code: 'describe(`Foo`, function () {})', |
| 121 | + errors: [ |
| 122 | + { |
| 123 | + message: '`describe`s should begin with lowercase', |
| 124 | + column: 1, |
| 125 | + line: 1, |
| 126 | + }, |
| 127 | + ], |
| 128 | + }, |
| 129 | + ], |
| 130 | +}); |
0 commit comments