From: Eduardo San Martin Morote Date: Mon, 16 Mar 2020 08:52:37 +0000 (+0100) Subject: test: redirect and redirectedFrom X-Git-Tag: v4.0.0-alpha.4~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ee41b34500da99c82d7c2040030cd4ebf0d1a2f;p=thirdparty%2Fvuejs%2Frouter.git test: redirect and redirectedFrom --- diff --git a/__tests__/router.spec.ts b/__tests__/router.spec.ts index 4e3bd4d9..fde357b2 100644 --- a/__tests__/router.spec.ts +++ b/__tests__/router.spec.ts @@ -310,9 +310,8 @@ describe('Router', () => { }) }) - describe('matcher', () => { - // TODO: rewrite after redirect refactor - it.skip('handles one redirect from route record', async () => { + describe('redirect', () => { + it('handles one redirect from route record', async () => { const history = createMemoryHistory() const router = createRouter({ history, routes }) const loc = await router.push('/to-foo') @@ -322,8 +321,17 @@ describe('Router', () => { }) }) - // TODO: rewrite after redirect refactor - it.skip('drops query and params on redirect if not provided', async () => { + it('handles a double redirect from route record', async () => { + const history = createMemoryHistory() + const router = createRouter({ history, routes }) + const loc = await router.push('/to-foo2') + expect(loc.name).toBe('Foo') + expect(loc.redirectedFrom).toMatchObject({ + path: '/to-foo2', + }) + }) + + it('drops query and params on redirect if not provided', async () => { const history = createMemoryHistory() const router = createRouter({ history, routes }) const loc = await router.push('/to-foo?hey=foo#fa') @@ -335,8 +343,7 @@ describe('Router', () => { }) }) - // TODO: rewrite after redirect refactor - it.skip('allows object in redirect', async () => { + it('allows object in redirect', async () => { const history = createMemoryHistory() const router = createRouter({ history, routes }) const loc = await router.push('/to-foo-named') @@ -346,8 +353,7 @@ describe('Router', () => { }) }) - // TODO: rewrite after redirect refactor - it.skip('can pass on query and hash when redirecting', async () => { + it('can pass on query and hash when redirecting', async () => { const history = createMemoryHistory() const router = createRouter({ history, routes }) const loc = await router.push('/inc-query-hash?n=3#fa') @@ -360,6 +366,8 @@ describe('Router', () => { }) expect(loc.redirectedFrom).toMatchObject({ fullPath: '/inc-query-hash?n=3#fa', + query: { n: '3' }, + hash: '#fa', path: '/inc-query-hash', }) })