@@ -7,14 +7,59 @@ define(function (require, exports, module) {
7
7
var route ;
8
8
9
9
it ( "match()" , function ( ) {
10
+ route = new Route ( '' , function ( ) { } , this ) ;
11
+ expect ( route . match ( '' ) ) . not . toBeNull ( ) ;
12
+ expect ( route . match ( '/' ) ) . not . toBeNull ( ) ;
13
+
14
+
15
+ route = new Route ( '/' , function ( ) { } , this ) ;
16
+ expect ( route . match ( '' ) ) . not . toBeNull ( ) ;
17
+ expect ( route . match ( '/' ) ) . not . toBeNull ( ) ;
18
+
19
+
10
20
route = new Route ( '/house/' , function ( ) { } , this ) ;
11
- expect ( route . match ( 'about' ) ) . toBeNull ( ) ;
21
+ expect ( route . match ( 'house' ) ) . not . toBeNull ( ) ;
22
+ expect ( route . match ( 'house/another' ) ) . toBeNull ( ) ;
23
+ // expect(route.match('house/another/?one=1&two=2&three=3')).not.toBeNull();
24
+ // expect(route.match('house/another?one=1&two=2&three=3')).not.toBeNull();
25
+
12
26
13
27
route = new Route ( '/games/{gameName}/:level:/' , function ( ) { } , this ) ;
14
28
expect ( route . match ( 'games/asteroids' ) ) . not . toBeNull ( ) ;
15
29
expect ( route . match ( '/games/asteroids/' ) ) . not . toBeNull ( ) ;
16
30
expect ( route . match ( '/games/asteroids/2' ) ) . not . toBeNull ( ) ;
17
31
expect ( route . match ( '/games/asteroids/2/' ) ) . not . toBeNull ( ) ;
32
+
33
+
34
+ route = new Route ( '/product/{productName}/' , function ( ) { } , this ) ;
35
+ expect ( route . match ( '/product/shoes/' ) ) . not . toBeNull ( ) ;
36
+ expect ( route . match ( '/product/jackets/' ) ) . not . toBeNull ( ) ;
37
+ expect ( route . match ( '/product/' ) ) . toBeNull ( ) ;
38
+
39
+
40
+ route = new Route ( '*' , function ( ) { } , this ) ;
41
+ expect ( route . match ( '/anything/' ) ) . not . toBeNull ( ) ;
42
+ expect ( route . match ( '/matches/any/hash/url/' ) ) . not . toBeNull ( ) ;
43
+ expect ( route . match ( '/really/it/matches/any/and/all/hash/urls/' ) ) . not . toBeNull ( ) ;
44
+
45
+
46
+ route = new Route ( '/about/*' , function ( ) { } , this ) ;
47
+ // expect(route.match('about')).not.toBeNull();
48
+ expect ( route . match ( '/about/' ) ) . not . toBeNull ( ) ;
49
+ expect ( route . match ( '/about/any/hash/url/' ) ) . not . toBeNull ( ) ;
50
+ expect ( route . match ( '/about/it/matches/any/and/all/hash/urls/' ) ) . not . toBeNull ( ) ;
51
+
52
+
53
+ route = new Route ( '?' , function ( ) { } , this ) ;
54
+ expect ( route . match ( '/?one=1&two=2&three=3' ) ) . not . toBeNull ( ) ;
55
+ expect ( route . match ( '?one=1&two=2&three=3' ) ) . not . toBeNull ( ) ;
56
+
57
+
58
+ route = new Route ( '/{category}/blog/' , function ( ) { } , this ) ;
59
+ expect ( route . match ( '/product/blog/' ) ) . not . toBeNull ( ) ;
60
+ expect ( route . match ( '/blog/blog/' ) ) . not . toBeNull ( ) ;
61
+ expect ( route . match ( '/car/blog/' ) ) . not . toBeNull ( ) ;
62
+ expect ( route . match ( '/blog/' ) ) . toBeNull ( ) ;
18
63
} ) ;
19
64
} ) ;
20
65
} ) ;
0 commit comments