cleanup MessageSearchResults
parent
792c23da87
commit
00d2bbc63d
@ -1,73 +0,0 @@
|
|||||||
import { assert } from 'chai';
|
|
||||||
import { LastMessageStatusType } from '../../state/ducks/conversations';
|
|
||||||
|
|
||||||
import * as Conversation from '../../types/Conversation';
|
|
||||||
import { IncomingMessage } from '../../types/Message';
|
|
||||||
|
|
||||||
describe('Conversation', () => {
|
|
||||||
describe('createLastMessageUpdate', () => {
|
|
||||||
it('should reset last message if conversation has no messages', () => {
|
|
||||||
const input = {};
|
|
||||||
const expected = {
|
|
||||||
lastMessage: '',
|
|
||||||
lastMessageStatus: undefined,
|
|
||||||
timestamp: undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
const actual = Conversation.createLastMessageUpdate(input);
|
|
||||||
assert.deepEqual(actual, expected);
|
|
||||||
});
|
|
||||||
|
|
||||||
context('for regular message', () => {
|
|
||||||
it('should update last message text and timestamp', () => {
|
|
||||||
const input = {
|
|
||||||
currentTimestamp: 555,
|
|
||||||
lastMessageStatus: 'read' as LastMessageStatusType,
|
|
||||||
lastMessage: {
|
|
||||||
type: 'outgoing',
|
|
||||||
conversationId: 'foo',
|
|
||||||
sent_at: 666,
|
|
||||||
timestamp: 666,
|
|
||||||
} as any,
|
|
||||||
lastMessageNotificationText: 'New outgoing message',
|
|
||||||
};
|
|
||||||
const expected = {
|
|
||||||
lastMessage: 'New outgoing message',
|
|
||||||
lastMessageStatus: 'read' as LastMessageStatusType,
|
|
||||||
timestamp: 666,
|
|
||||||
};
|
|
||||||
|
|
||||||
const actual = Conversation.createLastMessageUpdate(input);
|
|
||||||
assert.deepEqual(actual, expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
context('for expire timer update from sync', () => {
|
|
||||||
it('should update message but not timestamp (to prevent bump to top)', () => {
|
|
||||||
const input = {
|
|
||||||
currentTimestamp: 555,
|
|
||||||
lastMessage: {
|
|
||||||
type: 'incoming',
|
|
||||||
conversationId: 'foo',
|
|
||||||
sent_at: 666,
|
|
||||||
timestamp: 666,
|
|
||||||
expirationTimerUpdate: {
|
|
||||||
expireTimer: 111,
|
|
||||||
fromSync: true,
|
|
||||||
source: '+12223334455',
|
|
||||||
},
|
|
||||||
} as IncomingMessage,
|
|
||||||
lastMessageNotificationText: 'Last message before expired',
|
|
||||||
};
|
|
||||||
const expected = {
|
|
||||||
lastMessage: 'Last message before expired',
|
|
||||||
lastMessageStatus: undefined,
|
|
||||||
timestamp: 555,
|
|
||||||
};
|
|
||||||
|
|
||||||
const actual = Conversation.createLastMessageUpdate(input);
|
|
||||||
assert.deepEqual(actual, expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,137 +0,0 @@
|
|||||||
import { assert } from 'chai';
|
|
||||||
|
|
||||||
import * as Message from '../../../../ts/types/message/initializeAttachmentMetadata';
|
|
||||||
import { IncomingMessage } from '../../../../ts/types/Message';
|
|
||||||
import { SignalService } from '../../../../ts/protobuf';
|
|
||||||
import * as MIME from '../../../../ts/types/MIME';
|
|
||||||
// @ts-ignore
|
|
||||||
import { stringToArrayBuffer } from '../../../../js/modules/string_to_array_buffer';
|
|
||||||
|
|
||||||
describe('Message', () => {
|
|
||||||
describe('initializeAttachmentMetadata', () => {
|
|
||||||
it('should classify visual media attachments', async () => {
|
|
||||||
const input: IncomingMessage = {
|
|
||||||
type: 'incoming',
|
|
||||||
conversationId: 'foo',
|
|
||||||
id: '11111111-1111-1111-1111-111111111111',
|
|
||||||
timestamp: 1523317140899,
|
|
||||||
received_at: 1523317140899,
|
|
||||||
sent_at: 1523317140800,
|
|
||||||
attachments: [
|
|
||||||
{
|
|
||||||
contentType: MIME.IMAGE_JPEG,
|
|
||||||
data: stringToArrayBuffer('foo'),
|
|
||||||
fileName: 'foo.jpg',
|
|
||||||
size: 1111,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const expected: IncomingMessage = {
|
|
||||||
type: 'incoming',
|
|
||||||
conversationId: 'foo',
|
|
||||||
id: '11111111-1111-1111-1111-111111111111',
|
|
||||||
timestamp: 1523317140899,
|
|
||||||
received_at: 1523317140899,
|
|
||||||
sent_at: 1523317140800,
|
|
||||||
attachments: [
|
|
||||||
{
|
|
||||||
contentType: MIME.IMAGE_JPEG,
|
|
||||||
data: stringToArrayBuffer('foo'),
|
|
||||||
fileName: 'foo.jpg',
|
|
||||||
size: 1111,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
hasAttachments: 1,
|
|
||||||
hasVisualMediaAttachments: 1,
|
|
||||||
hasFileAttachments: undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
const actual = await Message.initializeAttachmentMetadata(input);
|
|
||||||
assert.deepEqual(actual, expected);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should classify file attachments', async () => {
|
|
||||||
const input: IncomingMessage = {
|
|
||||||
type: 'incoming',
|
|
||||||
conversationId: 'foo',
|
|
||||||
id: '11111111-1111-1111-1111-111111111111',
|
|
||||||
timestamp: 1523317140899,
|
|
||||||
received_at: 1523317140899,
|
|
||||||
sent_at: 1523317140800,
|
|
||||||
attachments: [
|
|
||||||
{
|
|
||||||
contentType: MIME.APPLICATION_OCTET_STREAM,
|
|
||||||
data: stringToArrayBuffer('foo'),
|
|
||||||
fileName: 'foo.bin',
|
|
||||||
size: 1111,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const expected: IncomingMessage = {
|
|
||||||
type: 'incoming',
|
|
||||||
conversationId: 'foo',
|
|
||||||
id: '11111111-1111-1111-1111-111111111111',
|
|
||||||
timestamp: 1523317140899,
|
|
||||||
received_at: 1523317140899,
|
|
||||||
sent_at: 1523317140800,
|
|
||||||
attachments: [
|
|
||||||
{
|
|
||||||
contentType: MIME.APPLICATION_OCTET_STREAM,
|
|
||||||
data: stringToArrayBuffer('foo'),
|
|
||||||
fileName: 'foo.bin',
|
|
||||||
size: 1111,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
hasAttachments: 1,
|
|
||||||
hasVisualMediaAttachments: undefined,
|
|
||||||
hasFileAttachments: 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
const actual = await Message.initializeAttachmentMetadata(input);
|
|
||||||
assert.deepEqual(actual, expected);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should classify voice message attachments', async () => {
|
|
||||||
const input: IncomingMessage = {
|
|
||||||
type: 'incoming',
|
|
||||||
conversationId: 'foo',
|
|
||||||
id: '11111111-1111-1111-1111-111111111111',
|
|
||||||
timestamp: 1523317140899,
|
|
||||||
received_at: 1523317140899,
|
|
||||||
sent_at: 1523317140800,
|
|
||||||
attachments: [
|
|
||||||
{
|
|
||||||
contentType: MIME.AUDIO_AAC,
|
|
||||||
flags: SignalService.AttachmentPointer.Flags.VOICE_MESSAGE,
|
|
||||||
data: stringToArrayBuffer('foo'),
|
|
||||||
fileName: 'Voice Message.aac',
|
|
||||||
size: 1111,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const expected: IncomingMessage = {
|
|
||||||
type: 'incoming',
|
|
||||||
conversationId: 'foo',
|
|
||||||
id: '11111111-1111-1111-1111-111111111111',
|
|
||||||
timestamp: 1523317140899,
|
|
||||||
received_at: 1523317140899,
|
|
||||||
sent_at: 1523317140800,
|
|
||||||
attachments: [
|
|
||||||
{
|
|
||||||
contentType: MIME.AUDIO_AAC,
|
|
||||||
flags: SignalService.AttachmentPointer.Flags.VOICE_MESSAGE,
|
|
||||||
data: stringToArrayBuffer('foo'),
|
|
||||||
fileName: 'Voice Message.aac',
|
|
||||||
size: 1111,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
hasAttachments: 1,
|
|
||||||
hasVisualMediaAttachments: undefined,
|
|
||||||
hasFileAttachments: undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
const actual = await Message.initializeAttachmentMetadata(input);
|
|
||||||
assert.deepEqual(actual, expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Reference in New Issue