Cable-Desktop/test/views/message_view_test.js

28 lines
886 B
JavaScript
Raw Normal View History

2014-09-01 20:52:58 +02:00
describe('MessageView', function() {
2014-10-29 20:53:54 +01:00
var thread = Whisper.Threads.add({id: 'foo'});
var message = thread.messages().add({
threadId: thread.id,
2014-09-01 20:52:58 +02:00
body: 'hello world',
type: 'outgoing',
timestamp: new Date().getTime()
});
2014-09-04 09:25:08 +02:00
it('should display the message text', function() {
2014-09-01 20:52:58 +02:00
var view = new Whisper.MessageView({model: message});
2014-09-04 09:25:08 +02:00
assert.match(view.render().$el.html(), /hello world/);
});
2014-09-01 20:52:58 +02:00
2014-09-04 09:25:08 +02:00
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/);
});
2014-09-01 20:52:58 +02:00
2014-09-04 09:25:08 +02:00
it('should go away when the model is destroyed', function() {
var view = new Whisper.MessageView({model: message});
var div = $('<div>').append(view.$el);
message.destroy();
assert.strictEqual(div.find(view.$el).length, 0);
2014-09-01 20:52:58 +02:00
});
});