Add tests for filtering left groups from search
// FREEBIE
This commit is contained in:
parent
7e8ce5eb54
commit
ef9559d844
2 changed files with 43 additions and 1 deletions
|
@ -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)) {
|
||||
|
|
|
@ -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 = $('<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 = $('<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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue