]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: add test for unencoded param
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 16 Aug 2019 16:28:47 +0000 (18:28 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 16 Aug 2019 16:28:47 +0000 (18:28 +0200)
__tests__/url-encoding.spec.js

index b21e2232920459122a8818f2a6c69617058ccdc7..d201b699b8eaf44e5dfc3b195c2df85191ef4d99 100644 (file)
@@ -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' },
+        })
+      )
+    })
   })
 })