Enhancement: Ability to assign administrators as conversation assignees (#2142)

* Enhancement: Ability to assign administrators as conversation assignee

Co-authored-by: Nithin David Thomas <webofnithin@gmail.com>
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Sivin Varghese
2021-04-22 23:17:29 +05:30
committed by GitHub
parent 87078e1abf
commit 285f7bbeb5
10 changed files with 178 additions and 5 deletions

View File

@@ -0,0 +1,36 @@
import axios from 'axios';
import { actions, types } from '../../inboxAssignableAgents';
import agentsData from './fixtures';
const commit = jest.fn();
global.axios = axios;
jest.mock('axios');
describe('#actions', () => {
describe('#fetch', () => {
it('sends correct actions if API is success', async () => {
axios.get.mockResolvedValue({
data: { payload: agentsData },
});
await actions.fetch({ commit }, { inboxId: 1 });
expect(commit.mock.calls).toEqual([
[types.SET_INBOX_ASSIGNABLE_AGENTS_UI_FLAG, { isFetching: true }],
[
types.SET_INBOX_ASSIGNABLE_AGENTS,
{ inboxId: 1, members: agentsData },
],
[types.SET_INBOX_ASSIGNABLE_AGENTS_UI_FLAG, { isFetching: false }],
]);
});
it('sends correct actions if API is error', async () => {
axios.get.mockRejectedValue({ message: 'Incorrect header' });
await expect(actions.fetch({ commit }, { inboxId: 1 })).rejects.toThrow(
Error
);
expect(commit.mock.calls).toEqual([
[types.SET_INBOX_ASSIGNABLE_AGENTS_UI_FLAG, { isFetching: true }],
[types.SET_INBOX_ASSIGNABLE_AGENTS_UI_FLAG, { isFetching: false }],
]);
});
});
});