-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed describes for tests related to this PR
- Loading branch information
1 parent
481de43
commit e52fa3d
Showing
3 changed files
with
50 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') | ||
}) |