2020-02-05 05:57:22 +00:00
|
|
|
import { mutations } from '../../agent';
|
2020-07-04 06:12:47 +00:00
|
|
|
import { agents } from './data';
|
2020-02-05 05:57:22 +00:00
|
|
|
|
|
|
|
describe('#mutations', () => {
|
|
|
|
describe('#setAgents', () => {
|
|
|
|
it('set agent records', () => {
|
|
|
|
const state = { records: [] };
|
|
|
|
mutations.setAgents(state, agents);
|
|
|
|
expect(state.records).toEqual(agents);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('#setError', () => {
|
|
|
|
it('set error flag', () => {
|
|
|
|
const state = { records: [], uiFlags: {} };
|
|
|
|
mutations.setError(state, true);
|
|
|
|
expect(state.uiFlags.isError).toEqual(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-01-12 10:55:27 +00:00
|
|
|
describe('#setHasFetched', () => {
|
2020-02-05 05:57:22 +00:00
|
|
|
it('set fetched flag', () => {
|
|
|
|
const state = { records: [], uiFlags: {} };
|
|
|
|
mutations.setHasFetched(state, true);
|
|
|
|
expect(state.uiFlags.hasFetched).toEqual(true);
|
|
|
|
});
|
|
|
|
});
|
2020-07-04 06:12:47 +00:00
|
|
|
|
|
|
|
describe('#updatePresence', () => {
|
|
|
|
it('updates agent presence', () => {
|
|
|
|
const state = { records: agents };
|
|
|
|
mutations.updatePresence(state, { 1: 'busy', 2: 'online' });
|
|
|
|
expect(state.records).toEqual([
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
name: 'John',
|
|
|
|
avatar_url: '',
|
|
|
|
availability_status: 'busy',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
name: 'Xavier',
|
|
|
|
avatar_url: '',
|
|
|
|
availability_status: 'online',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 3,
|
|
|
|
name: 'Pranav',
|
|
|
|
avatar_url: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 4,
|
|
|
|
name: 'Nithin',
|
|
|
|
avatar_url: '',
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
2020-02-05 05:57:22 +00:00
|
|
|
});
|