Skip to content

Commit 52f49c4

Browse files
committed
test(parser): add back the compare tests
1 parent 8fd197b commit 52f49c4

File tree

1 file changed

+37
-14
lines changed

1 file changed

+37
-14
lines changed

__tests__/matcher/path-ranking.spec.ts

+37-14
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,43 @@ import {
77
type PathParserOptions = Parameters<typeof tokensToParser>[1]
88

99
describe('Path ranking', () => {
10-
describe.skip('comparePathParser', () => {
11-
// it('same length', () => {
12-
// expect(comparePathParserScore([[2]], [[3]])).toEqual(1)
13-
// expect(comparePathParserScore([2], [2])).toEqual(0)
14-
// expect(comparePathParserScore([4], [3])).toEqual(-1)
15-
// })
16-
// it('longer', () => {
17-
// expect(comparePathParserScore([2], [3, 1])).toEqual(1)
18-
// // TODO: we are assuming we never pass end: false
19-
// expect(comparePathParserScore([3], [3, 1])).toEqual(1)
20-
// expect(comparePathParserScore([1, 3], [2])).toEqual(1)
21-
// expect(comparePathParserScore([4], [3])).toEqual(-1)
22-
// expect(comparePathParserScore([], [3])).toEqual(1)
23-
// })
10+
describe('comparePathParser', () => {
11+
function compare(a: number[][], b: number[][]): number {
12+
return comparePathParserScore(
13+
{
14+
score: a,
15+
re: /a/,
16+
// @ts-ignore
17+
stringify: v => v,
18+
// @ts-ignore
19+
parse: v => v,
20+
keys: [],
21+
},
22+
{
23+
score: b,
24+
re: /a/,
25+
// @ts-ignore
26+
stringify: v => v,
27+
// @ts-ignore
28+
parse: v => v,
29+
keys: [],
30+
}
31+
)
32+
}
33+
34+
it('same length', () => {
35+
expect(compare([[2]], [[3]])).toEqual(1)
36+
expect(compare([[2]], [[2]])).toEqual(0)
37+
expect(compare([[4]], [[3]])).toEqual(-1)
38+
})
39+
it('longer', () => {
40+
expect(compare([[2]], [[3, 1]])).toEqual(1)
41+
// TODO: we are assuming we never pass end: false
42+
expect(compare([[3]], [[3, 1]])).toEqual(1)
43+
expect(compare([[1, 3]], [[2]])).toEqual(1)
44+
expect(compare([[4]], [[3]])).toEqual(-1)
45+
expect(compare([], [[3]])).toEqual(1)
46+
})
2447
})
2548

2649
const possibleOptions: PathParserOptions[] = [

0 commit comments

Comments
 (0)