@@ -7,20 +7,43 @@ import {
7
7
type PathParserOptions = Parameters < typeof tokensToParser > [ 1 ]
8
8
9
9
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
+ } )
24
47
} )
25
48
26
49
const possibleOptions : PathParserOptions [ ] = [
0 commit comments