Fix tests

This commit is contained in:
lilia 2014-12-16 17:23:04 -08:00
parent 006653ed8e
commit 1a4811fcef
3 changed files with 16 additions and 10 deletions

View file

@ -89,7 +89,13 @@
before(function(done) {
var convo = new Whisper.ConversationCollection().add(attributes);
convo.save().then(function() {
var message = convo.messageCollection.add({body: 'hello world', conversationId: convo.id});
var message = convo.messageCollection.add({
body : 'hello world',
conversationId : convo.id,
type : 'outgoing',
sent_at : Date.now(),
received_at : Date.now()
});
message.save().then(done)
});
});

View file

@ -28,7 +28,7 @@
body: 'hi',
conversationId: 'foo',
attachments: [],
timestamp: new Date().getTime() };
received_at: new Date().getTime() };
describe('MessageCollection', function() {
before(clear);
@ -81,12 +81,12 @@
tomorrow.setDate(today.getDate()+1);
// Add threads
messages.add({ timestamp: today });
messages.add({ timestamp: tomorrow });
messages.add({ received_at: today });
messages.add({ received_at: tomorrow });
var models = messages.models;
var firstTimestamp = models[0].get('timestamp').getTime();
var secondTimestamp = models[1].get('timestamp').getTime();
var firstTimestamp = models[0].get('received_at').getTime();
var secondTimestamp = models[1].get('received_at').getTime();
// Compare timestamps
assert(firstTimestamp < secondTimestamp);

View file

@ -9,7 +9,7 @@ describe('MessageView', function() {
conversationId: convo.id,
body: 'hello world',
type: 'outgoing',
timestamp: new Date().getTime()
received_at: new Date().getTime()
});
it('should display the message text', function() {
@ -25,13 +25,13 @@ describe('MessageView', function() {
it('should have a nice timestamp', function() {
var view = new Whisper.MessageView({model: message});
message.set({'timestamp': new Date().getTime() - 5000});
message.set({'received_at': new Date().getTime() - 5000});
assert.match(view.$el.html(), /seconds ago/);
message.set({'timestamp': new Date().getTime() - 60000});
message.set({'received_at': new Date().getTime() - 60000});
assert.match(view.$el.html(), /minute ago/);
message.set({'timestamp': new Date().getTime() - 3600000});
message.set({'received_at': new Date().getTime() - 3600000});
assert.match(view.$el.html(), /hour ago/);
});