diff --git a/src/utilities/createRouter.spec.ts b/src/utilities/createRouter.spec.ts index baef300d..ea48aa39 100644 --- a/src/utilities/createRouter.spec.ts +++ b/src/utilities/createRouter.spec.ts @@ -1,49 +1,47 @@ -import { describe, expect, test } from 'vitest' +import { expect, test } from 'vitest' import { createRouter } from '@/utilities/createRouter' import { component } from '@/utilities/testHelpers' -describe('createRouter', () => { - test('initial route is set', () => { - const root = { - name: 'root', - component, - path: '/', - } +test('initial route is set', () => { + const root = { + name: 'root', + component, + path: '/', + } - const { route } = createRouter([root], { - initialUrl: root.path, - }) - - expect(route.matched).toMatchObject(root) + const { route } = createRouter([root], { + initialUrl: root.path, }) - test('throws error if route is not matched', () => { - expect(() => createRouter([], { - initialUrl: '/foo', - })).toThrowError('not implemented') + expect(route.matched).toMatchObject(root) +}) + +test('throws error if route is not matched', () => { + expect(() => createRouter([], { + initialUrl: '/foo', + })).toThrowError('not implemented') +}) + +test('updates the route when navigating', async () => { + const first = { + name: 'first', + component, + path: '/first', + } + + const second = { + name: 'second', + component, + path: '/second', + } + + const { push, route } = createRouter([first, second], { + initialUrl: first.path, }) - test('updates the route when navigating', async () => { - const first = { - name: 'first', - component, - path: '/first', - } - - const second = { - name: 'second', - component, - path: '/second', - } - - const { push, route } = createRouter([first, second], { - initialUrl: first.path, - }) + expect(route.matched).toMatchObject(first) - expect(route.matched).toMatchObject(first) + await push(second.path) - await push(second.path) - - expect(route.matched).toMatchObject(second) - }) + expect(route.matched).toMatchObject(second) }) \ No newline at end of file diff --git a/src/utilities/getInitialUrl.browser.spec.ts b/src/utilities/getInitialUrl.browser.spec.ts index 7fd322e8..0dd9f43b 100644 --- a/src/utilities/getInitialUrl.browser.spec.ts +++ b/src/utilities/getInitialUrl.browser.spec.ts @@ -1,23 +1,21 @@ -import { describe, expect, test, vi } from 'vitest' +import { expect, test, vi } from 'vitest' import { random } from '.' import { getInitialUrl } from '@/utilities/getInitialUrl' -describe('getInitialUrl', () => { - test('given value for initial route, returns value', () => { - const initialRoute = random.number().toString() +test('given value for initial route, returns value', () => { + const initialRoute = random.number().toString() - const response = getInitialUrl(initialRoute) + const response = getInitialUrl(initialRoute) - expect(response).toBe(initialRoute) - }) + expect(response).toBe(initialRoute) +}) - test('defaults to window.location', () => { - const initialRoute = random.number().toString() - vi.stubGlobal('location', initialRoute) +test('defaults to window.location', () => { + const initialRoute = random.number().toString() + vi.stubGlobal('location', initialRoute) - const response = getInitialUrl() + const response = getInitialUrl() - expect(response).toBe(initialRoute) - }) + expect(response).toBe(initialRoute) }) \ No newline at end of file diff --git a/src/utilities/getInitialUrl.spec.ts b/src/utilities/getInitialUrl.spec.ts index f5a4f0de..a64032ab 100644 --- a/src/utilities/getInitialUrl.spec.ts +++ b/src/utilities/getInitialUrl.spec.ts @@ -1,8 +1,6 @@ -import { describe, expect, test } from 'vitest' +import { expect, test } from 'vitest' import { getInitialUrl } from '@/utilities/getInitialUrl' -describe('getInitialUrl', () => { - test('throws error if initial route is not set', () => { - expect(() => getInitialUrl()).toThrowError('initialUrl must be set if window.location is unavailable') - }) +test('throws error if initial route is not set', () => { + expect(() => getInitialUrl()).toThrowError('initialUrl must be set if window.location is unavailable') }) \ No newline at end of file