From 6f2e9bd5c97df29580a036c47a042d1e7bc1b6d4 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sat, 14 Dec 2019 15:37:44 +0100 Subject: [PATCH] test: fix test helper --- __tests__/matcher/path-parser.spec.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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', () => { -- 2.47.2