documentcloud/backbone — Issue #678: Make unit testing routers easier
Author: jzaefferer
Created: 2011-10-17 10:44:37+00:00
State: open

Currently unit testing a router requires knowledge of router and history internals. I currently use this helper to trigger a router:

function hit(fragment) {
_.any(Backbone.history.handlers, function(handler) {
if (handler.route.test(fragment)) {
handler.callback(fragment);
return true;
}
});
}

Duplicating that in each testsuite and having to rely on so many Backbone internals to test a router is not maintainable.