fix: Update agent list when the user changes their presence (#1436)

This commit is contained in:
Pranav Raj S
2020-11-21 22:43:27 +05:30
committed by GitHub
parent 61d26f71c1
commit be2d3ea124
2 changed files with 23 additions and 2 deletions

View File

@@ -52,6 +52,24 @@ describe('#actions', () => {
});
});
describe('#updateAvailability', () => {
it('sends correct actions if API is success', async () => {
axios.put.mockResolvedValue({
data: { id: 1, name: 'John', availability_status: 'offline' },
headers: { expiry: 581842904 },
});
await actions.updateAvailability(
{ commit, dispatch },
{ availability: 'offline' }
);
expect(setUser).toHaveBeenCalledTimes(1);
expect(commit.mock.calls).toEqual([[types.default.SET_CURRENT_USER]]);
expect(dispatch.mock.calls).toEqual([
['agents/updatePresence', { 1: 'offline' }],
]);
});
});
describe('#setUser', () => {
it('sends correct actions if user is logged in', async () => {
Cookies.getJSON.mockImplementation(() => true);