2019-11-29 12:12:35 +00:00
|
|
|
import {
|
|
|
|
findUndeliveredMessage,
|
|
|
|
createTemporaryMessage,
|
2019-12-11 15:27:06 +00:00
|
|
|
} from '../../conversation';
|
2019-11-29 12:12:35 +00:00
|
|
|
|
|
|
|
describe('#findUndeliveredMessage', () => {
|
|
|
|
it('returns message objects if exist', () => {
|
|
|
|
const conversation = {
|
|
|
|
1: {
|
|
|
|
id: 1,
|
|
|
|
content: 'Hello',
|
|
|
|
status: 'in_progress',
|
|
|
|
},
|
|
|
|
2: {
|
|
|
|
id: 2,
|
|
|
|
content: 'Hello',
|
|
|
|
status: 'sent',
|
|
|
|
},
|
|
|
|
3: {
|
|
|
|
id: 3,
|
|
|
|
content: 'How may I help you',
|
|
|
|
status: 'sent',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(
|
|
|
|
findUndeliveredMessage(conversation, { content: 'Hello' })
|
|
|
|
).toStrictEqual([{ id: 1, content: 'Hello', status: 'in_progress' }]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('#createTemporaryMessage', () => {
|
|
|
|
it('returns message object', () => {
|
2020-03-30 06:45:06 +00:00
|
|
|
const message = createTemporaryMessage({ content: 'hello' });
|
2019-11-29 12:12:35 +00:00
|
|
|
expect(message.content).toBe('hello');
|
|
|
|
expect(message.status).toBe('in_progress');
|
|
|
|
});
|
|
|
|
});
|