-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
72 additions
and
24 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
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
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,16 +1,42 @@ | ||
import { describe, it } from 'vitest' | ||
import { describe, expectTypeOf, it } from 'vitest' | ||
import { NEW_LocationResolved, createCompiledMatcher } from './matcher' | ||
|
||
describe('Matcher', () => { | ||
it('resolves locations', () => { | ||
const matcher = createCompiledMatcher() | ||
matcher.resolve('/foo') | ||
// @ts-expect-error: needs currentLocation | ||
matcher.resolve('foo') | ||
matcher.resolve('foo', {} as NEW_LocationResolved) | ||
matcher.resolve({ name: 'foo', params: {} }) | ||
// @ts-expect-error: needs currentLocation | ||
matcher.resolve({ params: { id: 1 } }) | ||
matcher.resolve({ params: { id: 1 } }, {} as NEW_LocationResolved) | ||
const matcher = createCompiledMatcher() | ||
|
||
describe('matcher.resolve()', () => { | ||
it('resolves absolute string locations', () => { | ||
expectTypeOf( | ||
matcher.resolve('/foo') | ||
).toEqualTypeOf<NEW_LocationResolved>() | ||
}) | ||
|
||
it('fails on non absolute location without a currentLocation', () => { | ||
// @ts-expect-error: needs currentLocation | ||
matcher.resolve('foo') | ||
}) | ||
|
||
it('resolves relative locations', () => { | ||
expectTypeOf( | ||
matcher.resolve('foo', {} as NEW_LocationResolved) | ||
).toEqualTypeOf<NEW_LocationResolved>() | ||
}) | ||
|
||
it('resolved named locations', () => { | ||
expectTypeOf( | ||
matcher.resolve({ name: 'foo', params: {} }) | ||
).toEqualTypeOf<NEW_LocationResolved>() | ||
}) | ||
|
||
it('fails on object relative location without a currentLocation', () => { | ||
// @ts-expect-error: needs currentLocation | ||
matcher.resolve({ params: { id: 1 } }) | ||
}) | ||
|
||
it('resolves object relative locations with a currentLocation', () => { | ||
expectTypeOf( | ||
matcher.resolve({ params: { id: 1 } }, {} as NEW_LocationResolved) | ||
).toEqualTypeOf<NEW_LocationResolved>() | ||
}) | ||
}) | ||
}) |
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