Skip to content

Commit

Permalink
fixed branch
Browse files Browse the repository at this point in the history
  • Loading branch information
stackoverfloweth committed Jan 7, 2024
1 parent 26845be commit 481de43
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, expect, test } from 'vitest'
import { createRouter } from '@/utilities/createRouter'
import { component } from '@/utilities/testHelpers'

describe('getInitialRoute', () => {
describe('createRouter', () => {
test('initial route is set', () => {
const root = {
name: 'root',
Expand All @@ -18,7 +18,9 @@ describe('getInitialRoute', () => {
})

test('throws error if route is not matched', () => {
expect(() => createRouter([])).toThrowError('not implemented')
expect(() => createRouter([], {
initialUrl: '/foo',
})).toThrowError('not implemented')
})

test('updates the route when navigating', async () => {
Expand Down
17 changes: 0 additions & 17 deletions src/utilities/currentLocation.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/utilities/getInitialRoute.spec.ts

This file was deleted.

23 changes: 23 additions & 0 deletions src/utilities/getInitialUrl.browser.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { describe, 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()

const response = getInitialUrl(initialRoute)


expect(response).toBe(initialRoute)
})

test('defaults to window.location', () => {
const initialRoute = random.number().toString()
vi.stubGlobal('location', initialRoute)

const response = getInitialUrl()

expect(response).toBe(initialRoute)
})
})
8 changes: 8 additions & 0 deletions src/utilities/getInitialUrl.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { describe, 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')
})
})
File renamed without changes.
3 changes: 1 addition & 2 deletions src/utilities/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export * from './createRouteMethods'
export * from './createRouter'
export * from './currentLocation'
export * from './getInitialRoute'
export * from './getInitialUrl'
export * from './isBrowser'
export * from './mergeParams'
export * from './paramValidation'
Expand Down

0 comments on commit 481de43

Please sign in to comment.