From 4c86b645327298a57206fd367e029a813b8760a5 Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Sun, 13 Nov 2016 15:49:11 +0100 Subject: [PATCH] Improve contacts page jasmine test * append html to spec.content() instead of body * don't append the unused conversations modal fixture * actually test that showModal has been called --- spec/javascripts/app/pages/contacts_spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/javascripts/app/pages/contacts_spec.js b/spec/javascripts/app/pages/contacts_spec.js index 8574e6a5f..a1be4be48 100644 --- a/spec/javascripts/app/pages/contacts_spec.js +++ b/spec/javascripts/app/pages/contacts_spec.js @@ -280,16 +280,16 @@ describe("app.pages.Contacts", function(){ describe("showMessageModal", function() { beforeEach(function() { - $("body").append("
").append(spec.readFixture("conversations_modal")); + spec.content().append("
"); }); it("calls app.helpers.showModal", function() { spyOn(app.helpers, "showModal"); this.view.showMessageModal(); - expect(app.helpers.showModal); + expect(app.helpers.showModal).toHaveBeenCalled(); }); - it("app.views.ConversationsForm with correct parameters when modal is loaded", function() { + it("initializes app.views.ConversationsForm with correct parameters when modal is loaded", function() { gon.conversationPrefill = [ {id: 1, name: "diaspora user", handle: "diaspora-user@pod.tld"}, {id: 2, name: "other diaspora user", handle: "other-diaspora-user@pod.tld"}, @@ -299,7 +299,6 @@ describe("app.pages.Contacts", function(){ spyOn(app.views.ConversationsForm.prototype, "initialize"); this.view.showMessageModal(); $("#conversationModal").trigger("modal:loaded"); - expect($("#conversationModal").length).toBe(1); expect(app.views.ConversationsForm.prototype.initialize) .toHaveBeenCalledWith({prefill: gon.conversationPrefill}); });