From: Eduardo San Martin Morote Date: Fri, 16 Aug 2019 16:28:47 +0000 (+0200) Subject: test: add test for unencoded param X-Git-Tag: v4.0.0-alpha.0~266 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c75385c58aa6a6599c576f952dff754d40247a7;p=thirdparty%2Fvuejs%2Frouter.git test: add test for unencoded param --- 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' }, + }) + ) + }) }) })