]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test(parser): better test for wildcard
authorEduardo San Martin Morote <posva13@gmail.com>
Sun, 15 Dec 2019 18:12:46 +0000 (19:12 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Wed, 18 Dec 2019 09:26:15 +0000 (10:26 +0100)
__tests__/matcher/path-ranking.spec.ts

index 8627ea98648f31c9157d6660eb6f11f1075ebc6a..556ae2a217c0ad1693e0dda80cb465fff693f3d7 100644 (file)
@@ -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(.*)'])
+    })
+  })
 })