diff --git a/test/models/conversations_test.js b/test/models/conversations_test.js index 4da84661..ee4bc8c3 100644 --- a/test/models/conversations_test.js +++ b/test/models/conversations_test.js @@ -124,6 +124,44 @@ done(); }); }); + + it('adds conversation to message collection upon leaving group', function() { + var convo = new Whisper.ConversationCollection().add({type: 'group'}); + convo.leaveGroup(); + assert.notEqual(convo.messageCollection.length, 0); + }); + + it('has a title', function() { + var convos = new Whisper.ConversationCollection(); + var convo = convos.add(attributes); + assert.equal(convo.getTitle(), convo.id); + + convo = convos.add({type: ''}); + assert.equal(convo.getTitle(), 'Unknown group'); + + convo = convos.add({name: 'name'}); + assert.equal(convo.getTitle(), 'name'); + }); + + it('returns the number', function() { + var convos = new Whisper.ConversationCollection(); + var convo = convos.add(attributes); + assert.equal(convo.getNumber(), convo.id); + + convo = convos.add({type: ''}); + assert.equal(convo.getNumber(), ''); + }); + + it('has an avatar URL', function() { + var convo = new Whisper.ConversationCollection().add(attributes); + assert.equal(convo.getAvatarUrl(), '/images/default.png'); + }); + + it('revokes the avatar URL', function() { + var convo = new Whisper.ConversationCollection().add(attributes); + convo.revokeAvatarUrl(); + assert.notOk(convo.avatarUrl); + }); }); })();; diff --git a/test/models/messages_test.js b/test/models/messages_test.js index 9a53af77..1b012c78 100644 --- a/test/models/messages_test.js +++ b/test/models/messages_test.js @@ -92,5 +92,29 @@ assert(firstTimestamp < secondTimestamp); }); + it('checks if is incoming message', function() { + var messages = new Whisper.MessageCollection(); + var message = messages.add(attributes); + assert.notOk(message.isIncoming()); + message = messages.add({type: 'incoming'}); + assert.ok(message.isIncoming()); + }); + + it('checks if is outgoing message', function() { + var messages = new Whisper.MessageCollection(); + var message = messages.add(attributes); + assert.ok(message.isOutgoing()); + message = messages.add({type: 'incoming'}); + assert.notOk(message.isOutgoing()); + }); + + it('checks if is group update', function() { + var messages = new Whisper.MessageCollection(); + var message = messages.add(attributes); + assert.notOk(message.isGroupUpdate()); + + message = messages.add({group_update: true}); + assert.ok(message.isGroupUpdate()); + }); }); })();