Chatwoot/app/javascript/widget/store/modules/specs/conversation/utils.spec.js
Pranav Raj S 2b41e91768 [Enhancement] Fetch previous messages in the conversation (#355)
* Fetch previous messages in the conversation

* Add specs for conversation store

* Fix codeclimate issues

* Exclude specs folder

* Exclude globally

* Fix path in exclude patterns

* Add endPoints spec

* Add snapshots for Spinner

* Add specs for actions
2019-12-11 20:57:06 +05:30

37 lines
893 B
JavaScript

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', () => {
const message = createTemporaryMessage('hello');
expect(message.content).toBe('hello');
expect(message.status).toBe('in_progress');
});
});