Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding more tests for parsing

  • Loading branch information...
commit 9ae07295aa3f892fb41628dbaec4c1a94bfdf3c2 1 parent 8a233ff
Paul Kinlan authored
View
3  SpecRunner.html
@@ -11,7 +11,8 @@
<script type="text/javascript" src="routes.js"></script>
<!-- include spec files here... -->
- <script type="text/javascript" src="test.js"></script>
+ <script type="text/javascript" src="tests/routemanagement.js"></script>
+ <script type="text/javascript" src="tests/routeparsing.js"></script>
</head>
<body>
View
50 lib/jasmine/test.html
@@ -1,50 +0,0 @@
-<html>
- <head>
- <script src="lib/jasmine/jasmine.js"></script>
- <script src="routes.js"></script>
- <script>
- describe("route management", function() {
- var r;
- beforeEach(function() {
- r = new routes();
- });
-
- it("should have no routes", function() {
- expect(r.getRoutes().length).toEqual(1);
- });
-
- it("should have one route", function() {
- r.get("/", function() { });
- expect(r.getRoutes().length).toEqual(1);
- })
-
- if("should have two routes", function() {
- r.get("/index.html", function() {});
- r.get("/", function() { });
- expect(r.getRoutes().length).toEqual(2);
- });
- });
- </script>
-
- <script>
-
- (function() {
- var jasmineEnv = jasmine.getEnv();
- jasmineEnv.updateInterval = 1000;
-
- // var trivialReporter = new jasmine.TrivialReporter();
-
- // jasmineEnv.addReporter(trivialReporter);
-
- // jasmineEnv.specFilter = function(spec) {
- // return trivialReporter.specFilter(spec);
- // };
-
- window.onload = function() {
- jasmineEnv.execute();
- };
- })();
-
- </script>
- </head>
-</html>
View
6 test.js → tests/routemanagement.js
@@ -14,8 +14,8 @@ describe("route management", function() {
});
it("should have two routes", function() {
- r.get("/index.html", function() {});
- r.get("/", function() { });
- expect(r.getRoutes().length).toEqual(2);
+ r.get("/index.html", function() {});
+ r.get("/", function() { });
+ expect(r.getRoutes().length).toEqual(2);
});
});
View
22 tests/routeparsing.js
@@ -0,0 +1,22 @@
+describe("route parsing", function() {
+ var r;
+ beforeEach(function() {
+ r = new routes();
+ });
+
+ it("should parse / and add endmarker", function() {
+ r.get("/", function() { });
+ expect(r.getRoutes()[0].regex.regexp.source).toEqual("/$");
+ });
+
+ it("should parse basic route and leave untouched", function() {
+ r.get("/category", function() { });
+ expect(r.getRoutes()[0].regex.regexp.source).toEqual("/category$");
+ });
+
+ it("should parse basic named identifier in position 0", function() {
+ r.get("/:category", function(){});
+ expect(r.getRoutes()[0].regex.groups["category"]).toEqual(0);
+ expect(r.getRoutes()[0].regex.regexp.source).toEqual("/([^/.\\\\]+)$");
+ });
+});

0 comments on commit 9ae0729

Please sign in to comment.
Something went wrong with that request. Please try again.