fix #1619: fix navigation when root is empty

broken by commit d015ef1118
This commit is contained in:
Jerome Lecomte
2012-09-04 14:27:46 -04:00
parent 16001ca9a9
commit 1efeae70de
2 changed files with 40 additions and 1 deletions

View File

@@ -397,4 +397,37 @@ $(document).ready(function() {
});
});
test("#1619: Router: Normalize empty root", 1, function() {
Backbone.history.stop();
location.replace('http://example.com/');
Backbone.history = new Backbone.History({
location: location,
history: {
pushState: function(){},
replaceState: function(){}
}
});
Backbone.history.start({root: ''});
strictEqual(Backbone.history.root, '/');
});
test("#1619: Router: nagivate with empty root", 1, function() {
Backbone.history.stop();
location.replace('http://example.com/');
Backbone.history = new Backbone.History({
location: location,
history: {
pushState: function(state, title, url) {
strictEqual(url, '/fragment');
}
}
});
Backbone.history.start({
pushState: true,
root: '',
hashChange: false
});
Backbone.history.navigate('fragment');
});
});