]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: fix test helper
authorEduardo San Martin Morote <posva13@gmail.com>
Sat, 14 Dec 2019 14:37:44 +0000 (15:37 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Wed, 18 Dec 2019 09:26:15 +0000 (10:26 +0100)
__tests__/matcher/path-parser.spec.ts

index ed4eabccaca1370119c0ad6209c9ee640650a8dc..63b2b916f3ff10f812c13797417fb787d1b75fb4 100644 (file)
@@ -325,12 +325,19 @@ describe('Path parser', () => {
       ...args: Parameters<typeof tokensToParser>
     ) {
       const pathParser = tokensToParser(...args)
-      expect(expectedRe).toBe(
+      const options = args[1] || {}
+      // console.log(pathParser.re)
+      expect(
         pathParser.re
           .toString()
+          // remove the starting and ending slash of RegExp as well as any modifier
+          // /^\\/home$/i -> ^\\@home$
           .replace(/(:?^\/|\/\w*$)/g, '')
+          // remove escaped / to make it easier to write in tests
           .replace(/\\\//g, '/')
-      )
+          // only check the trailing slash if we provided a strict option
+          .replace(/\/\?\$?$/, 'strict' in options ? '$&' : '$')
+      ).toBe(expectedRe)
     }
 
     it('static single', () => {