From: Eduardo San Martin Morote Date: Fri, 12 Jun 2020 12:05:42 +0000 (+0200) Subject: test: silence warning logs X-Git-Tag: v4.0.0-alpha.13~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abe1b840ad3685ff1bc27a2725ed9e46d56a4891;p=thirdparty%2Fvuejs%2Frouter.git test: silence warning logs --- diff --git a/__tests__/errors.spec.ts b/__tests__/errors.spec.ts index 52c5cfd8..14139cf0 100644 --- a/__tests__/errors.spec.ts +++ b/__tests__/errors.spec.ts @@ -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() diff --git a/__tests__/router.spec.ts b/__tests__/router.spec.ts index 76425d60..b08edeec 100644 --- a/__tests__/router.spec.ts +++ b/__tests__/router.spec.ts @@ -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 () => {