From 037671f1b6d6f93793ab94f85a4daa44688c1cce Mon Sep 17 00:00:00 2001 From: Florian Staudacher Date: Thu, 20 Mar 2014 23:09:03 +0100 Subject: [PATCH] port remaining specs - jasmine is green again (non-CI) --- .../app/views/likes_info_view_spec.js | 6 +++--- .../app/views/publisher_view_spec.js | 4 ++-- .../javascripts/app/views/stream_post_spec.js | 4 ++-- .../javascripts/app/views/stream_view_spec.js | 19 ++++++++++--------- .../views/tag_following_action_view_spec.js | 10 +++++----- spec/javascripts/app/views_spec.js | 4 ++-- spec/javascripts/contact-list-spec.js | 2 +- spec/javascripts/widgets/back-to-top-spec.js | 6 +++--- .../widgets/flash-messages-spec.js | 2 +- .../javascripts/widgets/notifications-spec.js | 6 +++--- spec/javascripts/widgets/search-spec.js | 2 +- 11 files changed, 33 insertions(+), 32 deletions(-) diff --git a/spec/javascripts/app/views/likes_info_view_spec.js b/spec/javascripts/app/views/likes_info_view_spec.js index 2f33d6218..9f4648a20 100644 --- a/spec/javascripts/app/views/likes_info_view_spec.js +++ b/spec/javascripts/app/views/likes_info_view_spec.js @@ -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(){ diff --git a/spec/javascripts/app/views/publisher_view_spec.js b/spec/javascripts/app/views/publisher_view_spec.js index 8c0e1c6db..37e27fc45 100644 --- a/spec/javascripts/app/views/publisher_view_spec.js +++ b/spec/javascripts/app/views/publisher_view_spec.js @@ -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() { '' ); - spyOn(jQuery, 'ajax').andCallFake(function(opts) { opts.success(); }); + spyOn(jQuery, 'ajax').and.callFake(function(opts) { opts.success(); }); this.view.el_photozone.find('.x').click(); }); diff --git a/spec/javascripts/app/views/stream_post_spec.js b/spec/javascripts/app/views/stream_post_spec.js index 7f7de9b5e..319b09871 100644 --- a/spec/javascripts/app/views/stream_post_spec.js +++ b/spec/javascripts/app/views/stream_post_spec.js @@ -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(); }) }) diff --git a/spec/javascripts/app/views/stream_view_spec.js b/spec/javascripts/app/views/stream_view_spec.js index dac66b2fc..3935d13a2 100644 --- a/spec/javascripts/app/views/stream_view_spec.js +++ b/spec/javascripts/app/views/stream_view_spec.js @@ -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() }); }); diff --git a/spec/javascripts/app/views/tag_following_action_view_spec.js b/spec/javascripts/app/views/tag_following_action_view_spec.js index f82d60bb3..f2fbefc07 100644 --- a/spec/javascripts/app/views/tag_following_action_view_spec.js +++ b/spec/javascripts/app/views/tag_following_action_view_spec.js @@ -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) }) diff --git a/spec/javascripts/app/views_spec.js b/spec/javascripts/app/views_spec.js index e26eba16a..cf54c6eb0 100644 --- a/spec/javascripts/app/views_spec.js +++ b/spec/javascripts/app/views_spec.js @@ -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") }) }) }) diff --git a/spec/javascripts/contact-list-spec.js b/spec/javascripts/contact-list-spec.js index cd15181a4..6bafe6653 100644 --- a/spec/javascripts/contact-list-spec.js +++ b/spec/javascripts/contact-list-spec.js @@ -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(); diff --git a/spec/javascripts/widgets/back-to-top-spec.js b/spec/javascripts/widgets/back-to-top-spec.js index ea2e5337f..35543969a 100644 --- a/spec/javascripts/widgets/back-to-top-spec.js +++ b/spec/javascripts/widgets/back-to-top-spec.js @@ -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; }); -}); \ No newline at end of file +}); diff --git a/spec/javascripts/widgets/flash-messages-spec.js b/spec/javascripts/widgets/flash-messages-spec.js index 12bb2c0c2..f2e02bd9c 100644 --- a/spec/javascripts/widgets/flash-messages-spec.js +++ b/spec/javascripts/widgets/flash-messages-spec.js @@ -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(); }); diff --git a/spec/javascripts/widgets/notifications-spec.js b/spec/javascripts/widgets/notifications-spec.js index 84ded9b46..f67955f82 100644 --- a/spec/javascripts/widgets/notifications-spec.js +++ b/spec/javascripts/widgets/notifications-spec.js @@ -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(){ diff --git a/spec/javascripts/widgets/search-spec.js b/spec/javascripts/widgets/search-spec.js index 0e06516c2..e1f831af6 100644 --- a/spec/javascripts/widgets/search-spec.js +++ b/spec/javascripts/widgets/search-spec.js @@ -6,7 +6,7 @@ describe("Diaspora.Widgets.Search", function() { var search = Diaspora.BaseWidget.instantiate("Search", $("#jasmine_content > #searchForm")); var person = {"name": "