From: Eduardo San Martin Morote Date: Sat, 14 Dec 2019 14:37:44 +0000 (+0100) Subject: test: fix test helper X-Git-Tag: v4.0.0-alpha.0~149 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f2e9bd5c97df29580a036c47a042d1e7bc1b6d4;p=thirdparty%2Fvuejs%2Frouter.git test: fix test helper --- diff --git a/__tests__/matcher/path-parser.spec.ts b/__tests__/matcher/path-parser.spec.ts index ed4eabcc..63b2b916 100644 --- a/__tests__/matcher/path-parser.spec.ts +++ b/__tests__/matcher/path-parser.spec.ts @@ -325,12 +325,19 @@ describe('Path parser', () => { ...args: Parameters ) { 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', () => {