2020-05-14 08:13:02 +00:00
|
|
|
import commonHelpers from '../../../../helper/commons';
|
|
|
|
import getters from '../../conversations/getters';
|
|
|
|
|
|
|
|
// loads .last() helper
|
|
|
|
commonHelpers();
|
|
|
|
|
|
|
|
describe('#getters', () => {
|
|
|
|
describe('#getAllConversations', () => {
|
|
|
|
it('order conversations based on last message date', () => {
|
|
|
|
const state = {
|
|
|
|
allConversations: [
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
messages: [
|
|
|
|
{
|
|
|
|
created_at: 1466424480,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
messages: [
|
|
|
|
{
|
|
|
|
created_at: 2466424490,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
expect(getters.getAllConversations(state)).toEqual([
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
messages: [
|
|
|
|
{
|
|
|
|
created_at: 2466424490,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
messages: [
|
|
|
|
{
|
|
|
|
created_at: 1466424480,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
2021-03-20 12:12:29 +00:00
|
|
|
describe('#getUnAssignedChats', () => {
|
|
|
|
it('order returns only chats assigned to user', () => {
|
|
|
|
const conversationList = [
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
inbox_id: 2,
|
|
|
|
status: 1,
|
|
|
|
meta: { assignee: { id: 1 } },
|
|
|
|
labels: ['sales', 'dev'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
inbox_id: 2,
|
|
|
|
status: 1,
|
|
|
|
meta: {},
|
|
|
|
labels: ['dev'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 11,
|
|
|
|
inbox_id: 3,
|
|
|
|
status: 1,
|
|
|
|
meta: { assignee: { id: 1 } },
|
|
|
|
labels: [],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 22,
|
|
|
|
inbox_id: 4,
|
|
|
|
status: 1,
|
|
|
|
meta: { team: { id: 5 } },
|
|
|
|
labels: ['sales'],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
expect(
|
|
|
|
getters.getUnAssignedChats({ allConversations: conversationList })({
|
|
|
|
status: 1,
|
|
|
|
})
|
|
|
|
).toEqual([
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
inbox_id: 2,
|
|
|
|
status: 1,
|
|
|
|
meta: {},
|
|
|
|
labels: ['dev'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 22,
|
|
|
|
inbox_id: 4,
|
|
|
|
status: 1,
|
|
|
|
meta: { team: { id: 5 } },
|
|
|
|
labels: ['sales'],
|
|
|
|
},
|
|
|
|
]);
|
2020-05-14 08:13:02 +00:00
|
|
|
});
|
|
|
|
});
|
2021-07-05 06:31:54 +00:00
|
|
|
describe('#getConversationById', () => {
|
|
|
|
it('get conversations based on id', () => {
|
|
|
|
const state = {
|
|
|
|
allConversations: [
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
expect(getters.getConversationById(state)(1)).toEqual({ id: 1 });
|
|
|
|
});
|
|
|
|
});
|
2021-11-18 13:45:02 +00:00
|
|
|
|
2021-12-03 03:12:44 +00:00
|
|
|
describe('#getAppliedConversationFilters', () => {
|
|
|
|
it('getAppliedConversationFilters', () => {
|
2021-11-18 13:45:02 +00:00
|
|
|
const filtersList = [
|
|
|
|
{
|
|
|
|
attribute_key: 'status',
|
|
|
|
filter_operator: 'equal_to',
|
|
|
|
values: [{ id: 'snoozed', name: 'Snoozed' }],
|
|
|
|
query_operator: 'and',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
const state = {
|
|
|
|
appliedFilters: filtersList,
|
|
|
|
};
|
2021-12-03 03:12:44 +00:00
|
|
|
expect(getters.getAppliedConversationFilters(state)).toEqual(filtersList);
|
2021-11-18 13:45:02 +00:00
|
|
|
});
|
|
|
|
});
|
2020-05-14 08:13:02 +00:00
|
|
|
});
|