2019-12-11 15:27:06 +00:00
|
|
|
import { getters } from '../../conversation';
|
|
|
|
|
|
|
|
describe('#getters', () => {
|
|
|
|
it('getConversation', () => {
|
|
|
|
const state = {
|
|
|
|
conversations: {
|
|
|
|
1: {
|
|
|
|
content: 'hello',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(getters.getConversation(state)).toEqual({
|
|
|
|
1: {
|
|
|
|
content: 'hello',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('getConversationSize', () => {
|
|
|
|
const state = {
|
|
|
|
conversations: {
|
|
|
|
1: {
|
|
|
|
content: 'hello',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(getters.getConversationSize(state)).toEqual(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('getEarliestMessage', () => {
|
|
|
|
const state = {
|
|
|
|
conversations: {
|
|
|
|
1: {
|
|
|
|
content: 'hello',
|
|
|
|
},
|
|
|
|
2: {
|
|
|
|
content: 'hello1',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(getters.getEarliestMessage(state)).toEqual({
|
|
|
|
content: 'hello',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('uiFlags', () => {
|
|
|
|
const state = {
|
|
|
|
uiFlags: {
|
|
|
|
allMessagesLoaded: false,
|
|
|
|
isFetchingList: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(getters.getAllMessagesLoaded(state)).toEqual(false);
|
|
|
|
expect(getters.getIsFetchingList(state)).toEqual(false);
|
|
|
|
});
|
2019-12-14 18:36:01 +00:00
|
|
|
|
|
|
|
it('uiFlags', () => {
|
|
|
|
const state = {
|
|
|
|
conversations: {
|
|
|
|
1: {
|
|
|
|
id: 1,
|
|
|
|
content: 'Thanks for the help',
|
|
|
|
created_at: 1574075964,
|
2020-02-02 17:04:16 +00:00
|
|
|
message_type: 0,
|
2019-12-14 18:36:01 +00:00
|
|
|
},
|
|
|
|
2: {
|
|
|
|
id: 2,
|
|
|
|
content: 'Yes, It makes sense',
|
|
|
|
created_at: 1574092218,
|
2020-02-02 17:04:16 +00:00
|
|
|
message_type: 0,
|
2019-12-14 18:36:01 +00:00
|
|
|
},
|
|
|
|
3: {
|
|
|
|
id: 3,
|
|
|
|
content: 'Hey',
|
2020-02-02 17:04:16 +00:00
|
|
|
created_at: 1574092218,
|
|
|
|
message_type: 1,
|
2019-12-14 18:36:01 +00:00
|
|
|
},
|
|
|
|
4: {
|
|
|
|
id: 4,
|
2020-02-02 17:04:16 +00:00
|
|
|
content: 'Hey',
|
|
|
|
created_at: 1576340623,
|
|
|
|
},
|
|
|
|
5: {
|
|
|
|
id: 5,
|
2019-12-14 18:36:01 +00:00
|
|
|
content: 'How may I help you',
|
|
|
|
created_at: 1576340626,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2019-12-15 18:23:04 +00:00
|
|
|
expect(getters.getGroupedConversation(state)).toEqual([
|
|
|
|
{
|
|
|
|
date: 'Nov 18, 2019',
|
|
|
|
messages: [
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
content: 'Thanks for the help',
|
|
|
|
created_at: 1574075964,
|
|
|
|
showAvatar: false,
|
2020-02-02 17:04:16 +00:00
|
|
|
message_type: 0,
|
2019-12-15 18:23:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
content: 'Yes, It makes sense',
|
|
|
|
created_at: 1574092218,
|
|
|
|
showAvatar: true,
|
2020-02-02 17:04:16 +00:00
|
|
|
message_type: 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 3,
|
|
|
|
content: 'Hey',
|
|
|
|
created_at: 1574092218,
|
|
|
|
showAvatar: true,
|
|
|
|
message_type: 1,
|
2019-12-15 18:23:04 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
date: 'Dec 14, 2019',
|
|
|
|
messages: [
|
|
|
|
{
|
2020-02-02 17:04:16 +00:00
|
|
|
id: 4,
|
2019-12-15 18:23:04 +00:00
|
|
|
content: 'Hey',
|
|
|
|
created_at: 1576340623,
|
|
|
|
showAvatar: false,
|
|
|
|
},
|
|
|
|
{
|
2020-02-02 17:04:16 +00:00
|
|
|
id: 5,
|
2019-12-15 18:23:04 +00:00
|
|
|
content: 'How may I help you',
|
|
|
|
created_at: 1576340626,
|
|
|
|
showAvatar: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]);
|
2019-12-14 18:36:01 +00:00
|
|
|
});
|
2019-12-11 15:27:06 +00:00
|
|
|
});
|