Reorganize message view test a bit

pull/749/head
lilia 11 years ago
parent ef066ea9d2
commit 0cf5ae3bbf

@ -1,27 +1,25 @@
describe('MessageView', function() { describe('MessageView', function() {
var message = Whisper.Messages.add({ var message = Whisper.Messages.add({
threadId: 'test-thread',
body: 'hello world', body: 'hello world',
type: 'outgoing', type: 'outgoing',
timestamp: new Date().getTime() timestamp: new Date().getTime()
}); });
describe('#render', function() { it('should display the message text', function() {
var view = new Whisper.MessageView({model: message}); var view = new Whisper.MessageView({model: message});
var div = $('<div>').append(view.render().$el); assert.match(view.render().$el.html(), /hello world/);
});
it('should include the message text', function() {
assert.match(view.$el.html(), /hello world/);
});
it('should auto-update the message text', function() { it('should auto-update the message text', function() {
message.set('body', 'goodbye world'); var view = new Whisper.MessageView({model: message});
assert.match(view.$el.html(), /goodbye world/); message.set('body', 'goodbye world');
}); assert.match(view.$el.html(), /goodbye world/);
});
it('should go away when the model is destroyed', function() { it('should go away when the model is destroyed', function() {
message.destroy(); var view = new Whisper.MessageView({model: message});
assert.strictEqual(div.find(view.$el).length, 0); var div = $('<div>').append(view.$el);
}); message.destroy();
assert.strictEqual(div.find(view.$el).length, 0);
}); });
}); });

Loading…
Cancel
Save