port remaining specs - jasmine is green again (non-CI)

This commit is contained in:
Florian Staudacher 2014-03-20 23:09:03 +01:00 committed by Jonne Haß
parent 304e560e43
commit 037671f1b6
11 changed files with 33 additions and 32 deletions

View file

@ -16,13 +16,13 @@ describe("app.views.LikesInfo", function(){
describe(".render", function(){
it("displays a the like count if it is above zero", function() {
spyOn(this.view.model.interactions, "likesCount").andReturn(3);
spyOn(this.view.model.interactions, "likesCount").and.returnValue(3);
this.view.render();
expect($(this.view.el).find(".expand_likes").length).toBe(1)
})
it("does not display the like count if it is zero", function() {
spyOn(this.view.model.interactions, "likesCount").andReturn(0);
spyOn(this.view.model.interactions, "likesCount").and.returnValue(0);
this.view.render();
expect($(this.view.el).html().trim()).toBe("");
})
@ -36,7 +36,7 @@ describe("app.views.LikesInfo", function(){
describe("showAvatars", function(){
beforeEach(function(){
spyOn(this.post.interactions, "fetch").andCallThrough()
spyOn(this.post.interactions, "fetch").and.callThrough()
})
it("calls fetch on the model's like collection", function(){

View file

@ -166,7 +166,7 @@ describe("app.views.Publisher", function() {
it("should submit the form when ctrl+enter is pressed", function(){
this.view.render();
var form = this.view.$("form")
var submitCallback = jasmine.createSpy().andReturn(false);
var submitCallback = jasmine.createSpy().and.returnValue(false);
form.submit(submitCallback);
var e = $.Event("keydown", { keyCode: 13 });
@ -499,7 +499,7 @@ describe("app.views.Publisher", function() {
'</li>'
);
spyOn(jQuery, 'ajax').andCallFake(function(opts) { opts.success(); });
spyOn(jQuery, 'ajax').and.callFake(function(opts) { opts.success(); });
this.view.el_photozone.find('.x').click();
});

View file

@ -174,12 +174,12 @@ describe("app.views.StreamPost", function(){
})
it("destroys the view when they delete a their post from the show page", function(){
spyOn(window, "confirm").andReturn(true);
spyOn(window, "confirm").and.returnValue(true);
this.view.$(".remove_post").click();
expect(window.confirm).toHaveBeenCalled();
expect(this.view).not.toExist();
expect(this.view.el).not.toBeInDOM();
})
})

View file

@ -40,20 +40,21 @@ describe("app.views.Stream", function() {
describe("infScroll", function() {
// NOTE: inf scroll happens at 500px
beforeEach(function(){
spyOn($.fn, "height").andReturn(0);
spyOn($.fn, "scrollTop").andReturn(100);
spyOn($.fn, "height").and.returnValue(0);
spyOn($.fn, "scrollTop").and.returnValue(100);
spyOn(this.view.model, "fetch");
});
it("fetches moar when the user is at the bottom of the page", function() {
this.view.infScroll();
describe('fetching more', function() {
beforeEach(function(done) {
this.view.on('loadMore', function() {
done();
});
this.view.infScroll();
});
waitsFor(function(){
return this.view.model.fetch.wasCalled
}, "the infinite scroll function didn't fetch the stream");
runs(function(){
it("fetches moar when the user is at the bottom of the page", function() {
expect(this.view.model.fetch).toHaveBeenCalled()
});
});

View file

@ -7,13 +7,13 @@ describe("app.views.TagFollowingAction", function(){
describe("render", function(){
it("shows the output of followString", function(){
spyOn(this.view, "tag_is_followed").andReturn(false)
spyOn(this.view, "followString").andReturn("a_follow_string")
spyOn(this.view, "tag_is_followed").and.returnValue(false)
spyOn(this.view, "followString").and.returnValue("a_follow_string")
expect(this.view.render().$('input').val()).toMatch(/^a_follow_string$/)
})
it("should have the extra classes if the tag is followed", function(){
spyOn(this.view, "tag_is_followed").andReturn(true)
spyOn(this.view, "tag_is_followed").and.returnValue(true)
expect(this.view.render().$('input').hasClass("red_on_hover")).toBe(true)
expect(this.view.render().$('input').hasClass("in_aspects")).toBe(true)
})
@ -26,7 +26,7 @@ describe("app.views.TagFollowingAction", function(){
this.view.model.set("id", 3);
expect(this.view.tag_is_followed()).toBe(true);
spyOn(this.view.model, "destroy").andCallFake(_.bind(function(){
spyOn(this.view.model, "destroy").and.callFake(_.bind(function(){
// model.destroy leads to collection.remove, which is bound to getTagFollowing
this.view.getTagFollowing();
}, this) )
@ -39,7 +39,7 @@ describe("app.views.TagFollowingAction", function(){
it("toggles the tagFollowed from unfollowed to followed", function(){
expect(this.view.tag_is_followed()).toBe(false);
spyOn(app.tagFollowings, "create").andCallFake(function(model){
spyOn(app.tagFollowings, "create").and.callFake(function(model){
// 'save' the model by giving it an id
model.set("id", 3)
})

View file

@ -66,7 +66,7 @@ describe("app.views.Base", function(){
spyOn($.fn, "timeago")
this.view.render()
expect($.fn.timeago).toHaveBeenCalled()
expect($.fn.timeago.mostRecentCall.object.selector).toBe("time")
expect($.fn.timeago.calls.mostRecent().object.selector).toBe("time")
})
@ -75,7 +75,7 @@ describe("app.views.Base", function(){
spyOn($.fn, "tooltip")
this.view.render()
expect($.fn.tooltip.mostRecentCall.object.selector).toBe(".christopher_columbus, .barrack_obama, .block_user")
expect($.fn.tooltip.calls.mostRecent().object.selector).toBe(".christopher_columbus, .barrack_obama, .block_user")
})
})
})

View file

@ -10,7 +10,7 @@ describe("Contact List", function() {
spyOn($,'ajax');
List.disconnectUser(id);
expect($.ajax).toHaveBeenCalled();
var option_hash = $.ajax.mostRecentCall.args[0];
var option_hash = $.ajax.calls.mostRecent().args[0];
expect(option_hash.url).toEqual("/contacts/" + id);
expect(option_hash.type).toEqual("DELETE");
expect(option_hash.success).toBeDefined();

View file

@ -33,13 +33,13 @@ describe("Diaspora.Widgets.BackToTop", function() {
describe("toggleVisibility", function() {
it("adds a visibility class to the button", function() {
var spy = spyOn(backToTop.body, "scrollTop").andReturn(999);
var spy = spyOn(backToTop.body, "scrollTop").and.returnValue(999);
backToTop.toggleVisibility();
expect(backToTop.button.hasClass("visible")).toBe(false);
spy.andReturn(1001);
spy.and.returnValue(1001);
backToTop.toggleVisibility();
@ -50,4 +50,4 @@ describe("Diaspora.Widgets.BackToTop", function() {
afterEach(function() {
$.fx.off = false;
});
});
});

View file

@ -14,7 +14,7 @@ describe("Diaspora", function() {
});
it("is called when the DOM is ready", function() {
spyOn(flashMessages, "animateMessages").andCallThrough();
spyOn(flashMessages, "animateMessages").and.callThrough();
flashMessages.publish("widget/ready");
expect(flashMessages.animateMessages).toHaveBeenCalled();
});

View file

@ -11,9 +11,9 @@ describe("Diaspora.Widgets.Notifications", function() {
notifications = Diaspora.BaseWidget.instantiate("Notifications", this.view.$("#notification_badge .badge_count"), this.view.$(".notifications"));
changeNotificationCountSpy = spyOn(notifications, "changeNotificationCount").andCallThrough();
incrementCountSpy = spyOn(notifications, "incrementCount").andCallThrough();
decrementCountSpy = spyOn(notifications, "decrementCount").andCallThrough();
changeNotificationCountSpy = spyOn(notifications, "changeNotificationCount").and.callThrough();
incrementCountSpy = spyOn(notifications, "incrementCount").and.callThrough();
decrementCountSpy = spyOn(notifications, "decrementCount").and.callThrough();
});
describe("clickSuccess", function(){

View file

@ -6,7 +6,7 @@ describe("Diaspora.Widgets.Search", function() {
var search = Diaspora.BaseWidget.instantiate("Search", $("#jasmine_content > #searchForm"));
var person = {"name": "</script><script>alert('xss');</script"};
result = search.parse([$.extend({}, person)]);
expect(result[0].data.name).toNotEqual(person.name);
expect(result[0].data.name).not.toEqual(person.name);
});
});
});