]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: silence warning logs
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 12 Jun 2020 12:05:42 +0000 (14:05 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 12 Jun 2020 12:05:42 +0000 (14:05 +0200)
__tests__/errors.spec.ts
__tests__/router.spec.ts

index 52c5cfd89331341e4b5a3338ff1e907dab1abf35..14139cf0808999ff844d19190b566459d270d7bc 100644 (file)
@@ -8,6 +8,8 @@ const routes: RouteRecordRaw[] = [
   { path: '/', component: components.Home },
   { path: '/redirect', redirect: '/' },
   { path: '/foo', component: components.Foo, name: 'Foo' },
+  // prevent the log of no match warnings
+  { path: '/:pathMatch(.*)', component: components.Home },
 ]
 
 const onError = jest.fn()
index 76425d60da51fe0ad7d58475f1fbfac01620f9f6..b08edeece34d9c8c5db08b3c4e4c75f5cf54f314 100644 (file)
@@ -80,6 +80,8 @@ async function newRouter(
 }
 
 describe('Router', () => {
+  mockWarn()
+
   beforeAll(() => {
     createDom()
   })
@@ -252,6 +254,7 @@ describe('Router', () => {
     await router.push('/me-neither')
     expect(router.currentRoute.value).toMatchObject({ matched: [] })
     expect(spy).toHaveBeenCalledTimes(1)
+    expect('No match found').toHaveBeenWarnedTimes(2)
   })
 
   it('casts number params to string', async () => {
@@ -357,8 +360,6 @@ describe('Router', () => {
   })
 
   describe('Warnings', () => {
-    mockWarn()
-
     it.skip('avoid infinite redirection loops', async () => {
       const history = createMemoryHistory()
       let calls = 0
@@ -720,6 +721,7 @@ describe('Router', () => {
         name: undefined,
         matched: [],
       })
+      expect('No match found').toHaveBeenWarned()
       router.addRoute({
         path: '/new-route',
         component: components.Foo,
@@ -749,6 +751,7 @@ describe('Router', () => {
         name: undefined,
         matched: [],
       })
+      expect('No match found').toHaveBeenWarned()
       let removeRoute: (() => void) | undefined
       router.addRoute({
         path: '/dynamic',
@@ -816,6 +819,7 @@ describe('Router', () => {
       })
       // navigate again
       await router.replace('/new/child')
+      expect('No match found').toHaveBeenWarned()
       expect(router.currentRoute.value).toMatchObject({
         name: 'new-child',
       })
@@ -857,6 +861,7 @@ describe('Router', () => {
         name: undefined,
         matched: [],
       })
+      expect('No match found').toHaveBeenWarned()
     })
 
     it('can reroute when removing route', async () => {