|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const check = createRuleChecker('vue-router/root-option') |
| 4 | + |
| 5 | +describe('Rule: root-option', () => { |
| 6 | + it('does not match an empty line', () => { |
| 7 | + const warning = check('') |
| 8 | + expect(warning).toBe(null) |
| 9 | + }) |
| 10 | + |
| 11 | + it('does not match "root"', () => { |
| 12 | + const warning = check('root') |
| 13 | + expect(warning).toBe(null) |
| 14 | + }) |
| 15 | + |
| 16 | + it('does not match "root:"', () => { |
| 17 | + const warning = check('root:') |
| 18 | + expect(warning).toBe(null) |
| 19 | + }) |
| 20 | + |
| 21 | + it('does not match "root: \'\'"', () => { |
| 22 | + const warning = check('root: \'\'') |
| 23 | + expect(warning).toBe(null) |
| 24 | + }) |
| 25 | + |
| 26 | + it('does not match "root: \'foo\'"', () => { |
| 27 | + const warning = check('root: \'foo\'') |
| 28 | + expect(warning).toBe(null) |
| 29 | + }) |
| 30 | + |
| 31 | + it('matches "root: \'/\'"', () => { |
| 32 | + const warning = check(` |
| 33 | + root: '/' |
| 34 | + `) |
| 35 | + expect(warning).toBeTruthy() |
| 36 | + expect(warning.fix).toBe('Rename the root option to base') |
| 37 | + }) |
| 38 | + |
| 39 | + it('matches "root: "/""', () => { |
| 40 | + const warning = check(` |
| 41 | + root: "/" |
| 42 | + `) |
| 43 | + expect(warning).toBeTruthy() |
| 44 | + expect(warning.fix).toBe('Rename the root option to base') |
| 45 | + }) |
| 46 | + |
| 47 | + it('matches "root: `/`', () => { |
| 48 | + const warning = check(` |
| 49 | + root: \`/\` |
| 50 | + `) |
| 51 | + expect(warning).toBeTruthy() |
| 52 | + expect(warning.fix).toBe('Rename the root option to base') |
| 53 | + }) |
| 54 | + |
| 55 | + it('matches "root: \'/foo\'"', () => { |
| 56 | + const warning = check(` |
| 57 | + root: '/foo' |
| 58 | + `) |
| 59 | + expect(warning).toBeTruthy() |
| 60 | + expect(warning.fix).toBe('Rename the root option to base') |
| 61 | + }) |
| 62 | + |
| 63 | + it('matches "root: \'/foo/bar\'"', () => { |
| 64 | + const warning = check(` |
| 65 | + root: '/foo/bar' |
| 66 | + `) |
| 67 | + expect(warning).toBeTruthy() |
| 68 | + expect(warning.fix).toBe('Rename the root option to base') |
| 69 | + }) |
| 70 | +}) |
0 commit comments