|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const check = createRuleChecker('vue-router/arbitrary-route-properties') |
| 4 | + |
| 5 | +describe('Rule: arbitrary-route-properties', () => { |
| 6 | + it('does not match an empty line', () => { |
| 7 | + const warning = check('') |
| 8 | + expect(warning).toBe(null) |
| 9 | + }) |
| 10 | + |
| 11 | + it('does not match "route.meta"', () => { |
| 12 | + const warning = check('route.meta') |
| 13 | + expect(warning).toBe(null) |
| 14 | + }) |
| 15 | + |
| 16 | + it('does not match "route.path"', () => { |
| 17 | + const warning = check('route.path') |
| 18 | + expect(warning).toBe(null) |
| 19 | + }) |
| 20 | + |
| 21 | + it('does not match "route.query"', () => { |
| 22 | + const warning = check('route.query') |
| 23 | + expect(warning).toBe(null) |
| 24 | + }) |
| 25 | + |
| 26 | + it('does not match "route.redirect"', () => { |
| 27 | + const warning = check('route.query') |
| 28 | + expect(warning).toBe(null) |
| 29 | + }) |
| 30 | + |
| 31 | + it('matches "route.foo"', () => { |
| 32 | + const warning = check(` |
| 33 | + route.foo |
| 34 | + `) |
| 35 | + expect(warning).toBeTruthy() |
| 36 | + expect(warning.fix).toBe('Replace route.foo with route.meta.foo, then also update the route option to be scoped under meta') |
| 37 | + }) |
| 38 | + |
| 39 | + it('matches "route.foo.bar.baz"', () => { |
| 40 | + const warning = check(` |
| 41 | + route.foo.bar.baz |
| 42 | + `) |
| 43 | + expect(warning).toBeTruthy() |
| 44 | + expect(warning.fix).toBe('Replace route.foo with route.meta.foo, then also update the route option to be scoped under meta') |
| 45 | + }) |
| 46 | + |
| 47 | + it('matches "route.foo[1]"', () => { |
| 48 | + const warning = check(` |
| 49 | + route.foo[1] |
| 50 | + `) |
| 51 | + expect(warning).toBeTruthy() |
| 52 | + expect(warning.fix).toBe('Replace route.foo with route.meta.foo, then also update the route option to be scoped under meta') |
| 53 | + }) |
| 54 | +}) |
0 commit comments