|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const check = createRuleChecker('vue-router/loading-route-data') |
| 4 | + |
| 5 | +describe('Rule: loading-route-data', () => { |
| 6 | + it('does not match an empty line', () => { |
| 7 | + const warning = check('') |
| 8 | + expect(warning).toBe(null) |
| 9 | + }) |
| 10 | + |
| 11 | + it('does not match "loading route data"', () => { |
| 12 | + const warning = check('can reuse') |
| 13 | + expect(warning).toBe(null) |
| 14 | + }) |
| 15 | + |
| 16 | + it('does not match "loadingRouteData"', () => { |
| 17 | + const warning = check('loadingRouteData') |
| 18 | + expect(warning).toBe(null) |
| 19 | + }) |
| 20 | + |
| 21 | + it('matches "$loadingRouteData"', () => { |
| 22 | + const warning = check(` |
| 23 | + $loadingRouteData |
| 24 | + `) |
| 25 | + expect(warning).toBeTruthy() |
| 26 | + expect(warning.fix).toBe('Replace $loadingRouteData with a reactive property that you define (see the link below for an example)') |
| 27 | + }) |
| 28 | + |
| 29 | + it('matches "this.$loadingRouteData"', () => { |
| 30 | + const warning = check(` |
| 31 | + this.$loadingRouteData |
| 32 | + `) |
| 33 | + expect(warning).toBeTruthy() |
| 34 | + expect(warning.fix).toBe('Replace $loadingRouteData with a reactive property that you define (see the link below for an example)') |
| 35 | + }) |
| 36 | + |
| 37 | + it('matches "this.$loadingRouteData" surrounded by quotes', () => { |
| 38 | + const warning = check(` |
| 39 | + "$loadingRouteData" |
| 40 | + `) |
| 41 | + expect(warning).toBeTruthy() |
| 42 | + expect(warning.fix).toBe('Replace $loadingRouteData with a reactive property that you define (see the link below for an example)') |
| 43 | + }) |
| 44 | +}) |
0 commit comments