Chatwoot/app/javascript/dashboard/store/modules/specs/conversations/actions.spec.js
Pranav Raj S 2a4fb7b056
Bug: Fix conversation not loading from the links in email (#602)
Bug: Load conversation from links
2020-03-08 22:08:25 +05:30

24 lines
813 B
JavaScript

import axios from 'axios';
import actions from '../../conversations/actions';
import * as types from '../../../mutation-types';
const commit = jest.fn();
global.axios = axios;
jest.mock('axios');
describe('#actions', () => {
describe('#getConversation', () => {
it('sends correct actions if API is success', async () => {
axios.get.mockResolvedValue({ data: { id: 1, meta: {} } });
await actions.getConversation({ commit }, 1);
expect(commit.mock.calls).toEqual([
[types.default.ADD_CONVERSATION, { id: 1, meta: {} }],
]);
});
it('sends correct actions if API is error', async () => {
axios.get.mockRejectedValue({ message: 'Incorrect header' });
await actions.getConversation({ commit });
expect(commit.mock.calls).toEqual([]);
});
});
});