From 0c75385c58aa6a6599c576f952dff754d40247a7 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Fri, 16 Aug 2019 18:28:47 +0200 Subject: [PATCH] test: add test for unencoded param --- __tests__/url-encoding.spec.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/__tests__/url-encoding.spec.js b/__tests__/url-encoding.spec.js index b21e2232..d201b699 100644 --- a/__tests__/url-encoding.spec.js +++ b/__tests__/url-encoding.spec.js @@ -50,7 +50,6 @@ describe('URL Encoding', () => { }) it('allows navigating to valid unencoded params (IE and Edge)', async () => { - // /p/€ const history = createHistory('/p/€') const router = new Router({ history, routes }) await router.doInitialNavigation() @@ -65,5 +64,24 @@ describe('URL Encoding', () => { }) ) }) + + it('allows navigating to invalid unencoded params (IE and Edge)', async () => { + const spy = jest.spyOn(console, 'warn').mockImplementation(() => {}) + const history = createHistory('/p/%notvalid') + const router = new Router({ history, routes }) + await router.doInitialNavigation() + expect(spy).toHaveBeenCalledTimes(1) + spy.mockRestore() + expect(router.currentRoute).toEqual( + expect.objectContaining({ + name: undefined, + // unfortunately, we cannot encode the path as we cannot know if it already encoded + // so comparing fullPath and path here is pointless + // fullPath: '/p/€', + // only the params matter + params: { p: '%notvalid' }, + }) + ) + }) }) }) -- 2.47.3