diaspora/spec/javascripts/app/router_spec.js
Florian Staudacher 1924c40d38 replace vendored backbone.js/underscore.js with 'backbone-on-rails' gem
- updates underscore to 1.5.2 and backbone to 1.1.0

backbone had some breaking changes:
- fix url/urlRoot handling in models & collections
- options are no longer attached to the view by default
- collections reset when 'fetch' is called, tell it to keep the existing
  models

other changes:
- fix some events triggering multiple times in connection with deleting
  a model
- use document fragments instead of an element array for stream entries
- adapt jasmine and cucumber specs to the changed code
  * no longer test the backbone router as part of our code
  * jasmine factory already returns model instances, no need to wrap
    that again
2014-01-16 23:23:30 +01:00

72 lines
3.1 KiB
JavaScript

describe('app.Router', function () {
describe('followed_tags', function() {
it('decodes name before passing it into TagFollowingAction', function () {
var followed_tags = spyOn(app.router, 'followed_tags').andCallThrough();
var tag_following_action = spyOn(app.views, 'TagFollowingAction').andCallFake(function(data) {
return {render: function() { return {el: ""}}};
});
spyOn(window.history, 'pushState').andCallFake(function (data, title, url) {
var route = app.router._routeToRegExp("tags/:name");
var args = app.router._extractParameters(route, url.replace(/^\//, ""));
app.router.followed_tags(args[0]);
});
window.preloads = {tagFollowings: []};
app.router.navigate('/tags/'+encodeURIComponent('օբյեկտիվ'));
expect(followed_tags).toHaveBeenCalled();
expect(tag_following_action).toHaveBeenCalledWith({tagText: 'օբյեկտիվ'});
});
it('navigates to the downcase version of the corresponding tag', function () {
var followed_tags = spyOn(app.router, 'followed_tags').andCallThrough();
var tag_following_action = spyOn(app.views, 'TagFollowingAction').andCallFake(function(data) {
return {render: function() { return {el: ""}}};
});
spyOn(window.history, 'pushState').andCallFake(function (data, title, url) {
var route = app.router._routeToRegExp("tags/:name");
var args = app.router._extractParameters(route, url.replace(/^\//, ""));
app.router.followed_tags(args[0]);
});
window.preloads = {tagFollowings: []};
app.router.navigate('/tags/'+encodeURIComponent('SomethingWithCapitalLetters'));
expect(followed_tags).toHaveBeenCalled();
expect(tag_following_action).toHaveBeenCalledWith({tagText: 'somethingwithcapitalletters'});
});
});
describe("when routing to /stream and hiding inactive stream lists", function() {
var router;
var aspects;
var tagFollowings;
beforeEach(function() {
router = new app.Router();
});
it('calls hideInactiveStreamLists', function () {
var hideInactiveStreamLists = spyOn(router, 'hideInactiveStreamLists').andCallThrough();
router.stream();
expect(hideInactiveStreamLists).toHaveBeenCalled();
});
it('hides the aspects list', function(){
aspects = new app.collections.Aspects([{ name: 'Work', selected: true }]);
var aspectsListView = new app.views.AspectsList({collection: aspects});
var hideAspectsList = spyOn(aspectsListView, 'hideAspectsList').andCallThrough();
router.aspects_list = aspectsListView;
router.stream();
expect(hideAspectsList).toHaveBeenCalled();
});
it('hides the followed tags view', function(){
tagFollowings = new app.collections.TagFollowings();
var followedTagsView = new app.views.TagFollowingList({collection: tagFollowings});
var hideFollowedTags = spyOn(followedTagsView, 'hideFollowedTags').andCallThrough();
router.followedTagsView = followedTagsView;
router.stream();
expect(hideFollowedTags).toHaveBeenCalled();
});
});
});