From c9561809fbb5bf886c478e5d9c7707d5ff4a0bc3 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Tue, 17 Mar 2020 13:41:07 +0100 Subject: [PATCH] test: improve parseQuery test --- __tests__/router.spec.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/__tests__/router.spec.ts b/__tests__/router.spec.ts index 15952582..e6a9a966 100644 --- a/__tests__/router.spec.ts +++ b/__tests__/router.spec.ts @@ -55,12 +55,11 @@ const routes: RouteRecord[] = [ }, ] -async function newRouter({ - history, - ...args -}: Partial[0]> = {}) { - history = history || createMemoryHistory() - const router = createRouter({ history, routes, ...args }) +async function newRouter( + options: Partial[0]> = {} +) { + const history = options.history || createMemoryHistory() + const router = createRouter({ history, routes, ...options }) await router.push('/') return { history, router } @@ -92,18 +91,18 @@ describe('Router', () => { ) }) - it('can allows the end user to override parseQuery', async () => { + it('allows to customize parseQuery', async () => { const parseQuery = jest.fn() - const { router } = await newRouter({ parseQuery: parseQuery }) + const { router } = await newRouter({ parseQuery }) router.resolve('/foo?bar=baz') - expect(parseQuery).toHaveBeenCalled() + expect(parseQuery).toHaveBeenCalledWith('bar=baz') }) - it('can allows the end user to stringify the query', async () => { + it('allows to customize stringifyQuery', async () => { const stringifyQuery = jest.fn() - const { router } = await newRouter({ stringifyQuery: stringifyQuery }) + const { router } = await newRouter({ stringifyQuery }) router.resolve({ query: { foo: 'bar' } }) - expect(stringifyQuery).toHaveBeenCalled() + expect(stringifyQuery).toHaveBeenCalledWith({ foo: 'bar' }) }) it('can do initial navigation to /', async () => { -- 2.47.3