From 0cf5ae3bbfe3df843a9a7a6d316a72e383312c3c Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 4 Sep 2014 00:25:08 -0700 Subject: [PATCH] Reorganize message view test a bit --- test/views/message_view_test.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/test/views/message_view_test.js b/test/views/message_view_test.js index af4ac61a8..f75032e7b 100644 --- a/test/views/message_view_test.js +++ b/test/views/message_view_test.js @@ -1,27 +1,25 @@ describe('MessageView', function() { var message = Whisper.Messages.add({ - threadId: 'test-thread', body: 'hello world', type: 'outgoing', timestamp: new Date().getTime() }); - describe('#render', function() { + it('should display the message text', function() { var view = new Whisper.MessageView({model: message}); - var div = $('
').append(view.render().$el); - - it('should include the message text', function() { - assert.match(view.$el.html(), /hello world/); - }); + assert.match(view.render().$el.html(), /hello world/); + }); - it('should auto-update the message text', function() { - message.set('body', 'goodbye world'); - assert.match(view.$el.html(), /goodbye world/); - }); + it('should auto-update the message text', function() { + var view = new Whisper.MessageView({model: message}); + message.set('body', 'goodbye world'); + assert.match(view.$el.html(), /goodbye world/); + }); - it('should go away when the model is destroyed', function() { - message.destroy(); - assert.strictEqual(div.find(view.$el).length, 0); - }); + it('should go away when the model is destroyed', function() { + var view = new Whisper.MessageView({model: message}); + var div = $('
').append(view.$el); + message.destroy(); + assert.strictEqual(div.find(view.$el).length, 0); }); });