From: Eduardo San Martin Morote Date: Sun, 15 Dec 2019 18:12:46 +0000 (+0100) Subject: test(parser): better test for wildcard X-Git-Tag: v4.0.0-alpha.0~143 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a103f43364ab54feb587938e697401b690107d9c;p=thirdparty%2Fvuejs%2Frouter.git test(parser): better test for wildcard --- diff --git a/__tests__/matcher/path-ranking.spec.ts b/__tests__/matcher/path-ranking.spec.ts index 8627ea98..556ae2a2 100644 --- a/__tests__/matcher/path-ranking.spec.ts +++ b/__tests__/matcher/path-ranking.spec.ts @@ -73,12 +73,6 @@ describe('Path ranking', () => { checkPathOrder(['/a/b/c/d/e', '/:k/b/c/d/e', '/:k/b/c/d/:j']) }) - it('puts the wildcard at the end', () => { - checkPathOrder(['/', '/:rest(.*)']) - checkPathOrder(['/static', '/:rest(.*)']) - checkPathOrder(['/:other', '/:rest(.*)']) - }) - it('prioritises custom regex', () => { checkPathOrder(['/:a(\\d+)', '/:a', '/:a(.*)']) checkPathOrder(['/b-:a(\\d+)', '/b-:a', '/b-:a(.*)']) @@ -100,4 +94,27 @@ describe('Path ranking', () => { // checkPathOrder([['/a/', { strict: true }], '/a/']) // checkPathOrder([['/a', { strict: true }], '/a']) }) + + it('puts the wildcard at the end', () => { + const possibleOptions: PathParserOptions[] = [ + {}, + { strict: true, sensitive: false }, + { strict: false, sensitive: true }, + { strict: true, sensitive: true }, + ] + + possibleOptions.forEach(options => { + checkPathOrder([['', options], '/:rest(.*)']) + checkPathOrder([['/', options], '/:rest(.*)']) + checkPathOrder([['/ab', options], '/:rest(.*)']) + checkPathOrder([['/:a', options], '/:rest(.*)']) + checkPathOrder([['/:a?', options], '/:rest(.*)']) + checkPathOrder([['/:a+', options], '/:rest(.*)']) + checkPathOrder([['/:a*', options], '/:rest(.*)']) + checkPathOrder([['/:a(\\d+)', options], '/:rest(.*)']) + checkPathOrder([['/:a(\\d+)?', options], '/:rest(.*)']) + checkPathOrder([['/:a(\\d+)+', options], '/:rest(.*)']) + checkPathOrder([['/:a(\\d+)*', options], '/:rest(.*)']) + }) + }) })