Skip to content
This repository was archived by the owner on Dec 9, 2021. It is now read-only.

Commit 9ff8f64

Browse files
committed
add tests
1 parent a013720 commit 9ff8f64

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

test/controller/Route-Spec.js

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,59 @@ define(function (require, exports, module) {
77
var route;
88

99
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+
1020
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+
1226

1327
route = new Route('/games/{gameName}/:level:/', function(){}, this);
1428
expect(route.match('games/asteroids')).not.toBeNull();
1529
expect(route.match('/games/asteroids/')).not.toBeNull();
1630
expect(route.match('/games/asteroids/2')).not.toBeNull();
1731
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();
1863
});
1964
});
2065
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy