mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 11:37:58 +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>
65 lines
1.4 KiB
JavaScript
65 lines
1.4 KiB
JavaScript
import { API } from 'widget/helpers/axios';
|
|
import { actions } from '../../message';
|
|
|
|
const commit = vi.fn();
|
|
vi.mock('widget/helpers/axios');
|
|
|
|
describe('#actions', () => {
|
|
describe('#update', () => {
|
|
it('sends correct actions', async () => {
|
|
const user = {
|
|
email: 'john@acme.inc',
|
|
messageId: 10,
|
|
submittedValues: {
|
|
email: 'john@acme.inc',
|
|
},
|
|
};
|
|
API.patch.mockResolvedValue({
|
|
data: { contact: { pubsub_token: '8npuMUfDgizrwVoqcK1t7FMY' } },
|
|
});
|
|
await actions.update(
|
|
{
|
|
commit,
|
|
getters: {
|
|
getUIFlags: {
|
|
isUpdating: false,
|
|
},
|
|
},
|
|
},
|
|
user
|
|
);
|
|
expect(commit.mock.calls).toEqual([
|
|
['toggleUpdateStatus', true],
|
|
[
|
|
'conversation/updateMessage',
|
|
{
|
|
id: 10,
|
|
content_attributes: {
|
|
submitted_email: 'john@acme.inc',
|
|
submitted_values: null,
|
|
},
|
|
},
|
|
{ root: true },
|
|
],
|
|
['toggleUpdateStatus', false],
|
|
]);
|
|
});
|
|
|
|
it('blocks all new action calls when isUpdating', async () => {
|
|
await actions.update(
|
|
{
|
|
commit,
|
|
getters: {
|
|
getUIFlags: {
|
|
isUpdating: true,
|
|
},
|
|
},
|
|
},
|
|
{}
|
|
);
|
|
|
|
expect(commit.mock.calls).toEqual([]);
|
|
});
|
|
});
|
|
});
|