Due to the pattern `**/specs/*.spec.js` defined in CircleCI, none of the frontend spec in the folders such as `specs/<domain-name>/getters.spec.js` were not executed in Circle CI. This PR fixes the issue, along with the following changes: - Use vitest instead of jest - Remove jest dependancies - Update tests to work with vitest --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
45 lines
1.6 KiB
JavaScript
45 lines
1.6 KiB
JavaScript
import { actions } from '../../conversationSearch';
|
|
import types from '../../../mutation-types';
|
|
import axios from 'axios';
|
|
const commit = vi.fn();
|
|
global.axios = axios;
|
|
vi.mock('axios');
|
|
|
|
describe('#actions', () => {
|
|
describe('#get', () => {
|
|
it('sends correct actions if no query param is provided', () => {
|
|
actions.get({ commit }, { q: '' });
|
|
expect(commit.mock.calls).toEqual([[types.SEARCH_CONVERSATIONS_SET, []]]);
|
|
});
|
|
|
|
it('sends correct actions if query param is provided and API call is success', async () => {
|
|
axios.get.mockResolvedValue({
|
|
data: {
|
|
payload: [{ messages: [{ id: 1, content: 'value testing' }], id: 1 }],
|
|
},
|
|
});
|
|
|
|
await actions.get({ commit }, { q: 'value' });
|
|
expect(commit.mock.calls).toEqual([
|
|
[types.SEARCH_CONVERSATIONS_SET, []],
|
|
[types.SEARCH_CONVERSATIONS_SET_UI_FLAG, { isFetching: true }],
|
|
[
|
|
types.SEARCH_CONVERSATIONS_SET,
|
|
[{ messages: [{ id: 1, content: 'value testing' }], id: 1 }],
|
|
],
|
|
[types.SEARCH_CONVERSATIONS_SET_UI_FLAG, { isFetching: false }],
|
|
]);
|
|
});
|
|
|
|
it('sends correct actions if query param is provided and API call is errored', async () => {
|
|
axios.get.mockRejectedValue({});
|
|
await actions.get({ commit }, { q: 'value' });
|
|
expect(commit.mock.calls).toEqual([
|
|
[types.SEARCH_CONVERSATIONS_SET, []],
|
|
[types.SEARCH_CONVERSATIONS_SET_UI_FLAG, { isFetching: true }],
|
|
[types.SEARCH_CONVERSATIONS_SET_UI_FLAG, { isFetching: false }],
|
|
]);
|
|
});
|
|
});
|
|
});
|