Chatwoot/app/javascript/widget/store/modules/specs/conversation/utils.spec.js

38 lines
906 B
JavaScript
Raw Normal View History

import {
findUndeliveredMessage,
createTemporaryMessage,
} from '../../conversation';
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' });
expect(message.content).toBe('hello');
expect(message.status).toBe('in_progress');
});
});