diff --git a/test/models/messages_test.js b/test/models/messages_test.js index 42df82cd..f68a2692 100644 --- a/test/models/messages_test.js +++ b/test/models/messages_test.js @@ -18,10 +18,29 @@ attachments: [], received_at: new Date().getTime() }; + var attachment = { data: 'datasaurus', + contentType: 'plain/text' }; + describe('MessageCollection', function() { before(clear); after(clear); + it('has no image url', function() { + var messages = new Whisper.MessageCollection(); + var message = messages.add(attributes); + assert.isNull(message.getImageUrl()); + }); + + it('updates image url', function() { + var messages = new Whisper.MessageCollection(); + var message = messages.add({ attachments: [attachment] }); + + var firstUrl = message.getImageUrl(); + message.updateImageUrl(); + var secondUrl = message.getImageUrl(); + assert.notEqual(secondUrl, firstUrl); + }); + it('adds without saving', function() { var messages = new Whisper.MessageCollection(); var message = messages.add(attributes);