|
|
|
@ -33,6 +33,7 @@ describe('MessageCollection', () => {
|
|
|
|
|
const message = messages.add({
|
|
|
|
|
type: 'incoming',
|
|
|
|
|
source,
|
|
|
|
|
conversationId: 'conversationId',
|
|
|
|
|
});
|
|
|
|
|
message.getContact();
|
|
|
|
|
});
|
|
|
|
@ -45,8 +46,8 @@ describe('MessageCollection', () => {
|
|
|
|
|
tomorrow.setDate(today.getDate() + 1);
|
|
|
|
|
|
|
|
|
|
// Add threads
|
|
|
|
|
messages.add({ received_at: today });
|
|
|
|
|
messages.add({ received_at: tomorrow });
|
|
|
|
|
messages.add({ received_at: today, conversationId: 'conversationId' });
|
|
|
|
|
messages.add({ received_at: tomorrow, conversationId: 'conversationId' });
|
|
|
|
|
|
|
|
|
|
const { models } = messages;
|
|
|
|
|
const firstTimestamp = models[0].get('received_at').getTime();
|
|
|
|
@ -60,7 +61,10 @@ describe('MessageCollection', () => {
|
|
|
|
|
const messages = new window.models.Message.MessageCollection();
|
|
|
|
|
let message = messages.add(attributes);
|
|
|
|
|
assert.notOk(message.isIncoming());
|
|
|
|
|
message = messages.add({ type: 'incoming' });
|
|
|
|
|
message = messages.add({
|
|
|
|
|
type: 'incoming',
|
|
|
|
|
conversationId: 'conversationId',
|
|
|
|
|
});
|
|
|
|
|
assert.ok(message.isIncoming());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -68,7 +72,10 @@ describe('MessageCollection', () => {
|
|
|
|
|
const messages = new window.models.Message.MessageCollection();
|
|
|
|
|
let message = messages.add(attributes);
|
|
|
|
|
assert.ok(message.isOutgoing());
|
|
|
|
|
message = messages.add({ type: 'incoming' });
|
|
|
|
|
message = messages.add({
|
|
|
|
|
type: 'incoming',
|
|
|
|
|
conversationId: 'conversationId',
|
|
|
|
|
});
|
|
|
|
|
assert.notOk(message.isOutgoing());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -77,7 +84,10 @@ describe('MessageCollection', () => {
|
|
|
|
|
let message = messages.add(attributes);
|
|
|
|
|
assert.notOk(message.isGroupUpdate());
|
|
|
|
|
|
|
|
|
|
message = messages.add({ group_update: true });
|
|
|
|
|
message = messages.add({
|
|
|
|
|
group_update: true,
|
|
|
|
|
conversationId: 'conversationId',
|
|
|
|
|
});
|
|
|
|
|
assert.ok(message.isGroupUpdate());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -91,21 +101,30 @@ describe('MessageCollection', () => {
|
|
|
|
|
'If no group updates or end session flags, return message body.'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
message = messages.add({ group_update: { left: 'Alice' } });
|
|
|
|
|
message = messages.add({
|
|
|
|
|
group_update: { left: 'Alice' },
|
|
|
|
|
conversationId: 'conversationId',
|
|
|
|
|
});
|
|
|
|
|
assert.equal(
|
|
|
|
|
message.getDescription(),
|
|
|
|
|
'Alice has left the group.',
|
|
|
|
|
'Notes one person leaving the group.'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
message = messages.add({ group_update: { name: 'blerg' } });
|
|
|
|
|
message = messages.add({
|
|
|
|
|
group_update: { name: 'blerg' },
|
|
|
|
|
conversationId: 'conversationId',
|
|
|
|
|
});
|
|
|
|
|
assert.equal(
|
|
|
|
|
message.getDescription(),
|
|
|
|
|
"Group name is now 'blerg'.",
|
|
|
|
|
'Returns a single notice if only group_updates.name changes.'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
message = messages.add({ group_update: { joined: ['Bob'] } });
|
|
|
|
|
message = messages.add({
|
|
|
|
|
group_update: { joined: ['Bob'] },
|
|
|
|
|
conversationId: 'conversationId',
|
|
|
|
|
});
|
|
|
|
|
assert.equal(
|
|
|
|
|
message.getDescription(),
|
|
|
|
|
'Bob joined the group.',
|
|
|
|
@ -114,6 +133,7 @@ describe('MessageCollection', () => {
|
|
|
|
|
|
|
|
|
|
message = messages.add({
|
|
|
|
|
group_update: { joined: ['Bob', 'Alice', 'Eve'] },
|
|
|
|
|
conversationId: 'conversationId',
|
|
|
|
|
});
|
|
|
|
|
assert.equal(
|
|
|
|
|
message.getDescription(),
|
|
|
|
@ -123,6 +143,7 @@ describe('MessageCollection', () => {
|
|
|
|
|
|
|
|
|
|
message = messages.add({
|
|
|
|
|
group_update: { joined: ['Bob'], name: 'blerg' },
|
|
|
|
|
conversationId: 'conversationId',
|
|
|
|
|
});
|
|
|
|
|
assert.equal(
|
|
|
|
|
message.getDescription(),
|
|
|
|
|