Chatwoot/app/javascript/dashboard/store/modules/specs/dashboardApps/mutations.spec.js
Fayaz Ahmed ef1d117717
feat: Add the ability to create dashboard apps from the UI (#4924)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2022-07-08 15:55:32 +07:00

48 lines
1.7 KiB
JavaScript

import types from '../../../mutation-types';
import { mutations } from '../../dashboardApps';
import { automationsList } from './fixtures';
describe('#mutations', () => {
describe('#SET_DASHBOARD_APPS_UI_FLAG', () => {
it('set dashboard app ui flags', () => {
const state = { uiFlags: { isCreating: false, isUpdating: false } };
mutations[types.SET_DASHBOARD_APPS_UI_FLAG](state, { isUpdating: true });
expect(state.uiFlags).toEqual({ isCreating: false, isUpdating: true });
});
});
describe('#SET_DASHBOARD_APPS', () => {
it('set dashboard records', () => {
const state = { records: [{ title: 'Title 0' }] };
mutations[types.SET_DASHBOARD_APPS](state, [{ title: 'Title 1' }]);
expect(state.records).toEqual([{ title: 'Title 1' }]);
});
});
describe('#ADD_DASHBOARD_APP', () => {
it('push newly created app to the store', () => {
const state = { records: [automationsList[0]] };
mutations[types.CREATE_DASHBOARD_APP](state, automationsList[1]);
expect(state.records).toEqual([automationsList[0], automationsList[1]]);
});
});
describe('#EDIT_DASHBOARD_APP', () => {
it('update label record', () => {
const state = { records: [automationsList[0]] };
mutations[types.EDIT_DASHBOARD_APP](state, {
id: 15,
title: 'updated-title',
});
expect(state.records[0].title).toEqual('updated-title');
});
});
describe('#DELETE_DASHBOARD_APP', () => {
it('delete label record', () => {
const state = { records: [automationsList[0]] };
mutations[types.DELETE_DASHBOARD_APP](state, 15);
expect(state.records).toEqual([]);
});
});
});