From ef9559d844e4b74340f326bec13dd5194cc8dae9 Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 18 Feb 2016 23:28:24 -0800 Subject: [PATCH] Add tests for filtering left groups from search // FREEBIE --- js/views/conversation_search_view.js | 2 +- test/views/conversation_search_view_test.js | 42 +++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/js/views/conversation_search_view.js b/js/views/conversation_search_view.js index 4dc810ad..eb241cbb 100644 --- a/js/views/conversation_search_view.js +++ b/js/views/conversation_search_view.js @@ -53,7 +53,7 @@ 'click .new-contact': 'createConversation', }, - filterContacts: function(e) { + filterContacts: function() { var query = this.$input.val().trim(); if (query.length) { if (this.maybeNumber(query)) { diff --git a/test/views/conversation_search_view_test.js b/test/views/conversation_search_view_test.js index 4650df08..f48e6990 100644 --- a/test/views/conversation_search_view_test.js +++ b/test/views/conversation_search_view_test.js @@ -20,5 +20,47 @@ describe('ConversationSearchView', function() { assert.ok(view.maybeNumber(n), n); }); }); + describe('Searching for left groups', function() { + var convo = new Whisper.ConversationCollection().add({ + id: 'a-left-group', + name: 'i left this group', + members: [], + type: 'group', + left: true + }); + before(function(done) { + convo.save().then(done); + }); + describe('with no messages', function() { + var input = $(''); + var view = new Whisper.ConversationSearchView({ input: input }).render(); + before(function(done) { + view.$input.val('left'); + view.filterContacts(); + view.typeahead_view.collection.on('reset', function() { + done(); + }); + }); + it('should not surface left groups with no messages', function() { + assert.isUndefined(view.typeahead_view.collection.get(convo.id), 'got left group'); + }); + }); + describe('with messages', function() { + var input = $(''); + var view = new Whisper.ConversationSearchView({ input: input }).render(); + before(function(done) { + convo.save({lastMessage: 'asdf'}).then(function() { + view.$input.val('left'); + view.filterContacts(); + view.typeahead_view.collection.on('reset', function() { + done(); + }); + }); + }); + it('should surface left groups with messages', function() { + assert.isDefined(view.typeahead_view.collection.get(convo.id), 'got left group'); + }); + }); + }); });