Skip to content

Commit 7ed433b

Browse files
committed
test: static matcher
1 parent ef57c3e commit 7ed433b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

packages/router/src/new-route-resolver/matcher-pattern.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class MatcherPatternImpl implements MatcherPattern {
153153
query: MatcherQueryParams
154154
hash: string
155155
}) {
156-
// TODO: is this performant? Compare to a check with `null
156+
// TODO: is this performant? bench compare to a check with `null
157157
try {
158158
return [
159159
this.path.match(location.path),
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { MatcherPathStatic } from './path-static'
3+
4+
describe('PathStaticMatcher', () => {
5+
it('matches', () => {
6+
expect(new MatcherPathStatic('/').match('/')).toEqual({})
7+
expect(() => new MatcherPathStatic('/').match('/no')).toThrowError()
8+
expect(new MatcherPathStatic('/ok/ok').match('/ok/ok')).toEqual({})
9+
expect(() => new MatcherPathStatic('/ok/ok').match('/ok/no')).toThrowError()
10+
})
11+
12+
it('builds path', () => {
13+
expect(new MatcherPathStatic('/').buildPath()).toBe('/')
14+
expect(new MatcherPathStatic('/ok').buildPath()).toBe('/ok')
15+
expect(new MatcherPathStatic('/ok/ok').buildPath()).toEqual('/ok/ok')
16+
})
17+
})

0 commit comments

Comments
 (0)