mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Fix tests
This commit is contained in:
@@ -89,7 +89,7 @@
|
||||
before(function(done) {
|
||||
var convo = new Whisper.ConversationCollection().add(attributes);
|
||||
convo.save().then(function() {
|
||||
var message = convo.messages().add({body: 'hello world', conversationId: convo.id});
|
||||
var message = convo.messageCollection.add({body: 'hello world', conversationId: convo.id});
|
||||
message.save().then(done)
|
||||
});
|
||||
});
|
||||
@@ -97,16 +97,16 @@
|
||||
|
||||
it('contains its own messages', function (done) {
|
||||
var convo = new Whisper.ConversationCollection().add({id: 'foobar'});
|
||||
convo.fetch().then(function() {
|
||||
assert.notEqual(convo.messages().length, 0);
|
||||
convo.fetchMessages().then(function() {
|
||||
assert.notEqual(convo.messageCollection.length, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('contains only its own messages', function (done) {
|
||||
var convo = new Whisper.ConversationCollection().add({id: 'barfoo'});
|
||||
convo.fetch().then(function() {
|
||||
assert.strictEqual(convo.messages().length, 0);
|
||||
convo.fetchMessages().then(function() {
|
||||
assert.strictEqual(convo.messageCollection.length, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -72,5 +72,25 @@
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should be ordered oldest to newest', function() {
|
||||
var messages = new Whisper.MessageCollection();
|
||||
// Timestamps
|
||||
var today = new Date();
|
||||
var tomorrow = new Date();
|
||||
tomorrow.setDate(today.getDate()+1);
|
||||
|
||||
// Add threads
|
||||
messages.add({ timestamp: today });
|
||||
messages.add({ timestamp: tomorrow });
|
||||
|
||||
var models = messages.models;
|
||||
var firstTimestamp = models[0].get('timestamp').getTime();
|
||||
var secondTimestamp = models[1].get('timestamp').getTime();
|
||||
|
||||
// Compare timestamps
|
||||
assert(firstTimestamp < secondTimestamp);
|
||||
});
|
||||
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user