Chatwoot/app/javascript/dashboard/store/modules/specs/agents/getters.spec.js
Aswin Dev P.S 676796ddc7
feat: Add reports about live agent load (#4537)
* feat: Add reports about live agent load
2022-04-25 07:34:41 -07:00

147 lines
3 KiB
JavaScript

import { getters } from '../../agents';
describe('#getters', () => {
it('getAgents', () => {
const state = {
records: [
{
id: 1,
name: 'Agent 1',
email: 'agent1@chatwoot.com',
confirmed: true,
},
{
id: 2,
name: 'Agent 2',
email: 'agent2@chatwoot.com',
confirmed: false,
},
],
};
expect(getters.getAgents(state)).toEqual([
{
id: 1,
name: 'Agent 1',
email: 'agent1@chatwoot.com',
confirmed: true,
},
{
id: 2,
name: 'Agent 2',
email: 'agent2@chatwoot.com',
confirmed: false,
},
]);
});
it('getVerifiedAgents', () => {
const state = {
records: [
{
id: 1,
name: 'Agent 1',
email: 'agent1@chatwoot.com',
confirmed: true,
},
{
id: 2,
name: 'Agent 2',
email: 'agent2@chatwoot.com',
confirmed: false,
},
],
};
expect(getters.getVerifiedAgents(state)).toEqual([
{
id: 1,
name: 'Agent 1',
email: 'agent1@chatwoot.com',
confirmed: true,
},
]);
});
it('getUIFlags', () => {
const state = {
uiFlags: {
isFetching: true,
isCreating: false,
isUpdating: false,
isDeleting: false,
},
};
expect(getters.getUIFlags(state)).toEqual({
isFetching: true,
isCreating: false,
isUpdating: false,
isDeleting: false,
});
});
it('getAgentStatus', () => {
const state = {
records: [
{
id: 1,
name: 'Agent 1',
email: 'agent1@chatwoot.com',
confirmed: true,
availability_status: 'online',
},
{
id: 2,
name: 'Agent 2',
email: 'agent2@chatwoot.com',
confirmed: false,
availability_status: 'offline',
},
],
};
expect(getters.getAgentStatus(state)).toEqual({
online: 1,
busy: 0,
offline: 1,
});
});
it('getAgentStatus', () => {
const state = {
records: [
{
id: 1,
name: 'Agent 1',
email: 'agent1@chatwoot.com',
confirmed: true,
availability_status: 'online',
},
{
id: 2,
name: 'Agent 2',
email: 'agent2@chatwoot.com',
confirmed: false,
availability_status: 'offline',
},
],
};
expect(getters.getAgentStatus(state)).toEqual({
online: 1,
busy: 0,
offline: 1,
});
});
it('getAgentStatus', () => {
const state = {
records: [
{
id: 1,
name: 'Agent 1',
email: 'agent1@chatwoot.com',
confirmed: true,
availability_status: 'online',
},
],
};
expect(getters.getAgentsCount(state)).toEqual(1);
});
});