Created
November 2, 2012 04:22
-
-
Save djbriane/3998698 to your computer and use it in GitHub Desktop.
Backbone.js - Tests for Route with Trailing Spaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test("#XXXX Trailing spaces (pushState:false).", 1, function() { | |
var count = 0; | |
Backbone.history.stop(); | |
// restart History with pushState:false | |
Backbone.history.start({ | |
pushState: false | |
}); | |
router.on("route:search", function(page) { | |
count = count + 1; | |
}); | |
// navigate to the search route with trailing space in the query string | |
Backbone.history.navigate('search/space ', {trigger: true}); | |
// manually fire checkUrl | |
Backbone.history.checkUrl(); | |
equal(count, 1); // route event should be fired once | |
router.off("route:search"); //unbind events | |
}); | |
test("#XXXX Trailing spaces using browser location (pushState: false).", 1, function() { | |
var count = 0; | |
Backbone.history.stop(); | |
Backbone.history.location = window.location; // Use browser location | |
// restart History with pushState:false | |
Backbone.history.start({ | |
pushState: false | |
}); | |
router.on("route:search", function(page) { | |
count = count + 1; | |
}); | |
// navigate to the search route with trailing space in the query string | |
Backbone.history.navigate('search/space ', {trigger: true}); | |
// manually fire checkUrl | |
Backbone.history.checkUrl(); | |
equal(count, 1); // route event should be fired only once | |
router.off("route:search"); //unbind events | |
// restore location hash | |
window.location.hash = ''; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment