Fix tests
This commit is contained in:
parent
006653ed8e
commit
1a4811fcef
3 changed files with 16 additions and 10 deletions
|
@ -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)
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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/);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue