mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 03:27:52 +00:00
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>
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import { API } from 'widget/helpers/axios';
|
|
import { actions } from '../../agent';
|
|
import { agents } from './data';
|
|
|
|
const commit = vi.fn();
|
|
vi.mock('widget/helpers/axios');
|
|
|
|
describe('#actions', () => {
|
|
describe('#fetchAvailableAgents', () => {
|
|
it('sends correct actions if API is success', async () => {
|
|
API.get.mockResolvedValue({ data: { payload: agents } });
|
|
await actions.fetchAvailableAgents({ commit }, 'Hi');
|
|
expect(commit.mock.calls).toEqual([
|
|
['setAgents', agents],
|
|
['setError', false],
|
|
['setHasFetched', true],
|
|
]);
|
|
});
|
|
it('sends correct actions if API is error', async () => {
|
|
API.get.mockRejectedValue({ message: 'Authentication required' });
|
|
await actions.fetchAvailableAgents({ commit }, 'Hi');
|
|
expect(commit.mock.calls).toEqual([
|
|
['setError', true],
|
|
['setHasFetched', true],
|
|
]);
|
|
});
|
|
});
|
|
|
|
describe('#updatePresence', () => {
|
|
it('commits the correct presence value', () => {
|
|
actions.updatePresence({ commit }, { 1: 'online' });
|
|
expect(commit.mock.calls).toEqual([['updatePresence', { 1: 'online' }]]);
|
|
});
|
|
});
|
|
});
|