Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1011 from wookiehangover/issue996

adding test coverage for route precedence as per issue #996
  • Loading branch information...
commit e5db1c93d084b74a9cc3fe2dae4798372eee6ff1 2 parents 16b37e7 + 8d8a359
@jashkenas jashkenas authored
Showing with 27 additions and 0 deletions.
  1. +27 −0 test/router.js
View
27 test/router.js
@@ -37,6 +37,9 @@ $(document).ready(function() {
"counter": "counter",
"search/:query": "search",
"search/:query/p:page": "search",
+ "contacts": "contacts",
+ "contacts/new": "newContact",
+ "contacts/:id": "loadContact",
"splat/*args/end": "splat",
"*first/complex-:part/*rest": "complex",
":entity?*args": "query",
@@ -61,6 +64,18 @@ $(document).ready(function() {
this.page = page;
},
+ contacts: function(){
+ this.contact = 'index';
+ },
+
+ newContact: function(){
+ this.contact = 'new';
+ },
+
+ loadContact: function(){
+ this.contact = 'load';
+ },
+
splat : function(args) {
this.args = args;
},
@@ -120,6 +135,18 @@ $(document).ready(function() {
equal(router.page, '20');
});
+ test("Router: route precedence via navigate", 6, function(){
+ // check both 0.9.x and backwards-compatibility options
+ _.each([ { trigger: true }, true ], function( options ){
+ Backbone.history.navigate('contacts', options);
+ equal(router.contact, 'index');
+ Backbone.history.navigate('contacts/new', options);
+ equal(router.contact, 'new');
+ Backbone.history.navigate('contacts/foo', options);
+ equal(router.contact, 'load');
+ });
+ });
+
test("Router: doesn't fire routes to the same place twice", function() {
equal(router.count, 0);
router.navigate('counter', {trigger: true});
Please sign in to comment.
Something went wrong with that request. Please try again.