Files
Pranav 9de8c27368 feat: Use vitest instead of jest, run all the specs anywhere in app/ folder in the CI (#9722)
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>
2024-07-10 08:32:16 -07:00

40 lines
1.3 KiB
JavaScript

import { actions } from '../../conversationAttributes';
import { API } from 'widget/helpers/axios';
const commit = vi.fn();
vi.mock('widget/helpers/axios');
describe('#actions', () => {
describe('#get attributes', () => {
it('sends mutation if api is success', async () => {
API.get.mockResolvedValue({ data: { id: 1, status: 'pending' } });
await actions.getAttributes({ commit });
expect(commit.mock.calls).toEqual([
['SET_CONVERSATION_ATTRIBUTES', { id: 1, status: 'pending' }],
['conversation/setMetaUserLastSeenAt', undefined, { root: true }],
]);
});
it('doesnot send mutation if api is error', async () => {
API.get.mockRejectedValue({ message: 'Invalid Headers' });
await actions.getAttributes({ commit });
expect(commit.mock.calls).toEqual([]);
});
});
describe('#update attributes', () => {
it('sends correct mutations', () => {
actions.update({ commit }, { id: 1, status: 'pending' });
expect(commit).toBeCalledWith('UPDATE_CONVERSATION_ATTRIBUTES', {
id: 1,
status: 'pending',
});
});
});
describe('#clear attributes', () => {
it('sends correct mutations', () => {
actions.clearConversationAttributes({ commit });
expect(commit).toBeCalledWith('CLEAR_CONVERSATION_ATTRIBUTES');
});
});
});