From cbe3ca5cf62c0f137c0560fde268e985b83731e6 Mon Sep 17 00:00:00 2001
From: Steffen van Bergerem <svbergerem@omgsrsly.net>
Date: Sun, 13 Nov 2016 16:02:27 +0100
Subject: [PATCH] Improve conversations form jasmine test

* test that tag element are removed when clicking the tag's remove button
---
 .../app/views/conversations_form_view_spec.js       | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/spec/javascripts/app/views/conversations_form_view_spec.js b/spec/javascripts/app/views/conversations_form_view_spec.js
index 97760a0677..46c170f3ae 100644
--- a/spec/javascripts/app/views/conversations_form_view_spec.js
+++ b/spec/javascripts/app/views/conversations_form_view_spec.js
@@ -43,13 +43,13 @@ describe("app.views.ConversationsForm", function() {
       $("#conversation-show").addClass("hidden");
     });
 
-    it("add the participant", function() {
+    it("adds the participant", function() {
       expect(this.target.conversationRecipients).toEqual([]);
       this.target.addRecipient({name: "diaspora user", handle: "diaspora-user@pod.tld"});
       expect(this.target.conversationRecipients).toEqual([{name: "diaspora user", handle: "diaspora-user@pod.tld"}]);
     });
 
-    it("call updateContactIdsListInput", function() {
+    it("calls updateContactIdsListInput", function() {
       spyOn(app.views.ConversationsForm.prototype, "updateContactIdsListInput");
       this.target.addRecipient({name: "diaspora user", handle: "diaspora-user@pod.tld"});
       expect(app.views.ConversationsForm.prototype.updateContactIdsListInput).toHaveBeenCalled();
@@ -67,7 +67,7 @@ describe("app.views.ConversationsForm", function() {
       this.prefills = [{name: "diaspora user"}, {name: "other diaspora user"}, {name: "user"}];
     });
 
-    it("call addRecipient for each prefilled participant", function() {
+    it("calls addRecipient for each prefilled participant", function() {
       spyOn(app.views.ConversationsForm.prototype, "addRecipient");
       this.target.prefill(this.prefills);
       expect(app.views.ConversationsForm.prototype.addRecipient).toHaveBeenCalledTimes(this.prefills.length);
@@ -115,7 +115,7 @@ describe("app.views.ConversationsForm", function() {
   });
 
   describe("onSuggestionSelection", function() {
-    it("calls addRecipient, updateContactIdsListInput and $.fn.typeahead", function() {
+    it("calls addRecipient and $.fn.typeahead", function() {
       spyOn(app.views.ConversationsForm.prototype, "addRecipient");
       spyOn($.fn, "typeahead");
       var person = {name: "diaspora user"};
@@ -208,10 +208,15 @@ describe("app.views.ConversationsForm", function() {
     it("removes the tag element when clicking the tag's remove button", function() {
       expect($("[data-diaspora-handle='diaspora-user@pod.tld']").length).toBe(1);
       $("[data-diaspora-handle='diaspora-user@pod.tld'] .remove").click();
+      expect($("[data-diaspora-handle='diaspora-user@pod.tld']").length).toBe(0);
+
       expect($("[data-diaspora-handle='other-diaspora-user@pod.tld']").length).toBe(1);
       $("[data-diaspora-handle='other-diaspora-user@pod.tld'] .remove").click();
+      expect($("[data-diaspora-handle='other-diaspora-user@pod.tld']").length).toBe(0);
+
       expect($("[data-diaspora-handle='user@pod.tld']").length).toBe(1);
       $("[data-diaspora-handle='user@pod.tld'] .remove").click();
+      expect($("[data-diaspora-handle='user@pod.tld']").length).toBe(0);
     });
 
     it("calls updateContactIdsListInput", function() {
-- 
GitLab