From: Eduardo San Martin Morote Date: Tue, 17 Mar 2020 12:41:07 +0000 (+0100) Subject: test: improve parseQuery test X-Git-Tag: v4.0.0-alpha.4~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9561809fbb5bf886c478e5d9c7707d5ff4a0bc3;p=thirdparty%2Fvuejs%2Frouter.git test: improve parseQuery test --- 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 () => {