diff --git a/spec/javascripts/app/views/feedback_view_spec.js b/spec/javascripts/app/views/feedback_view_spec.js index 654b57710..cc6b5da35 100644 --- a/spec/javascripts/app/views/feedback_view_spec.js +++ b/spec/javascripts/app/views/feedback_view_spec.js @@ -1,6 +1,7 @@ describe("app.views.Feedback", function(){ beforeEach(function(){ - loginAs({id : -1, name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); + this.userAttrs = _.extend(factory.userAttrs(), {guid : -1}); + loginAs(this.userAttrs); Diaspora.I18n.load({stream : { 'like' : "Like", @@ -55,19 +56,18 @@ describe("app.views.Feedback", function(){ }); it("the like action should be 'Like'", function(){ - expect(this.link().text()).toContain(Diaspora.I18n.t('stream.like')); + expect(this.link().text()).toContain(Diaspora.I18n.t("stream.like")); }); it("allows for unliking a just-liked post", function(){ - // callback stuff.... we should fix this - - // expect(this.link().text()).toContain(Diaspora.I18n.t('stream.like')) - - // this.link().click(); - // expect(this.link().text()).toContain(Diaspora.I18n.t('stream.unlike')) - - // this.link().click(); - // expect(this.link().text()).toContain(Diaspora.I18n.t('stream.like')) + var responseText = JSON.stringify({"author": this.userAttrs}); + var ajax_success = { status: 201, responseText: responseText }; + expect(this.link().text()).toContain(Diaspora.I18n.t("stream.like")); + this.link().click(); + jasmine.Ajax.requests.mostRecent().respondWith(ajax_success); + expect(this.link().text()).toContain(Diaspora.I18n.t("stream.unlike")); + this.link().click(); + expect(this.link().text()).toContain(Diaspora.I18n.t("stream.like")); }); }); }); diff --git a/spec/javascripts/app/views/photos_view_spec.js b/spec/javascripts/app/views/photos_view_spec.js index 6c24f5e6e..f01aec0c8 100644 --- a/spec/javascripts/app/views/photos_view_spec.js +++ b/spec/javascripts/app/views/photos_view_spec.js @@ -16,24 +16,24 @@ describe("app.views.Photos", function() { }, this); }); -// describe("initialize", function() { -// it("binds an infinite scroll listener", function() { -// spyOn($.fn, "scroll"); -// new app.views.Stream({model : this.stream}); -// expect($.fn.scroll).toHaveBeenCalled(); -// }); -// }); -// -// describe("#render", function() { -// beforeEach(function() { -// this.photo = this.stream.items.models[0]; -// this.photoElement = $(this.view.$("#" + this.photo.get("guid"))); -// }); -// -// context("when rendering a photo message", function() { -// it("shows the photo in the content area", function() { -// expect(this.photoElement.length).toBeGreaterThan(0); //markdown'ed -// }); -// }); -// }); + describe("initialize", function() { + it("binds an infinite scroll listener", function() { + spyOn($.fn, "scroll"); + new app.views.Stream({model : this.stream}); + expect($.fn.scroll).toHaveBeenCalled(); + }); + }); + + describe("#render", function() { + beforeEach(function() { + this.photo = this.stream.items.models[0]; + this.photoElement = $(this.view.$("#" + this.photo.get("guid"))); + }); + + context("when rendering a photo message", function() { + it("shows the photo in the content area", function() { + expect(this.photoElement.length).toBeGreaterThan(0); + }); + }); + }); });