2020-10-24 23:57:45 +05:30
|
|
|
import testAction from 'helpers/vuex_action_helper';
|
2021-01-29 00:20:46 +05:30
|
|
|
import {
|
|
|
|
setOverride,
|
|
|
|
setIsSaving,
|
|
|
|
setIsTesting,
|
|
|
|
setIsResetting,
|
2021-02-22 17:27:13 +05:30
|
|
|
requestResetIntegration,
|
|
|
|
receiveResetIntegrationSuccess,
|
|
|
|
receiveResetIntegrationError,
|
2021-03-11 19:13:27 +05:30
|
|
|
requestJiraIssueTypes,
|
|
|
|
receiveJiraIssueTypesSuccess,
|
|
|
|
receiveJiraIssueTypesError,
|
2021-01-29 00:20:46 +05:30
|
|
|
} from '~/integrations/edit/store/actions';
|
2020-07-28 23:09:34 +05:30
|
|
|
import * as types from '~/integrations/edit/store/mutation_types';
|
2021-03-11 19:13:27 +05:30
|
|
|
import createState from '~/integrations/edit/store/state';
|
|
|
|
import { refreshCurrentPage } from '~/lib/utils/url_utility';
|
2020-07-28 23:09:34 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
jest.mock('~/lib/utils/url_utility');
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
describe('Integration form store actions', () => {
|
|
|
|
let state;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
state = createState();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setOverride', () => {
|
|
|
|
it('should commit override mutation', () => {
|
|
|
|
return testAction(setOverride, true, state, [{ type: types.SET_OVERRIDE, payload: true }]);
|
|
|
|
});
|
|
|
|
});
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
describe('setIsSaving', () => {
|
|
|
|
it('should commit isSaving mutation', () => {
|
|
|
|
return testAction(setIsSaving, true, state, [{ type: types.SET_IS_SAVING, payload: true }]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setIsTesting', () => {
|
|
|
|
it('should commit isTesting mutation', () => {
|
|
|
|
return testAction(setIsTesting, true, state, [{ type: types.SET_IS_TESTING, payload: true }]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setIsResetting', () => {
|
|
|
|
it('should commit isResetting mutation', () => {
|
|
|
|
return testAction(setIsResetting, true, state, [
|
|
|
|
{ type: types.SET_IS_RESETTING, payload: true },
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
2021-02-22 17:27:13 +05:30
|
|
|
|
|
|
|
describe('requestResetIntegration', () => {
|
|
|
|
it('should commit REQUEST_RESET_INTEGRATION mutation', () => {
|
|
|
|
return testAction(requestResetIntegration, null, state, [
|
|
|
|
{ type: types.REQUEST_RESET_INTEGRATION },
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('receiveResetIntegrationSuccess', () => {
|
|
|
|
it('should call refreshCurrentPage()', () => {
|
|
|
|
return testAction(receiveResetIntegrationSuccess, null, state, [], [], () => {
|
|
|
|
expect(refreshCurrentPage).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('receiveResetIntegrationError', () => {
|
|
|
|
it('should commit RECEIVE_RESET_INTEGRATION_ERROR mutation', () => {
|
|
|
|
return testAction(receiveResetIntegrationError, null, state, [
|
|
|
|
{ type: types.RECEIVE_RESET_INTEGRATION_ERROR },
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
describe('requestJiraIssueTypes', () => {
|
|
|
|
it('should commit SET_JIRA_ISSUE_TYPES_ERROR_MESSAGE and SET_IS_LOADING_JIRA_ISSUE_TYPES mutations', () => {
|
|
|
|
return testAction(requestJiraIssueTypes, null, state, [
|
|
|
|
{ type: types.SET_JIRA_ISSUE_TYPES_ERROR_MESSAGE, payload: '' },
|
|
|
|
{ type: types.SET_IS_LOADING_JIRA_ISSUE_TYPES, payload: true },
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('receiveJiraIssueTypesSuccess', () => {
|
|
|
|
it('should commit SET_IS_LOADING_JIRA_ISSUE_TYPES and SET_JIRA_ISSUE_TYPES mutations', () => {
|
|
|
|
const issueTypes = ['issue', 'epic'];
|
|
|
|
return testAction(receiveJiraIssueTypesSuccess, issueTypes, state, [
|
|
|
|
{ type: types.SET_IS_LOADING_JIRA_ISSUE_TYPES, payload: false },
|
|
|
|
{ type: types.SET_JIRA_ISSUE_TYPES, payload: issueTypes },
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('receiveJiraIssueTypesError', () => {
|
|
|
|
it('should commit SET_IS_LOADING_JIRA_ISSUE_TYPES, SET_JIRA_ISSUE_TYPES and SET_JIRA_ISSUE_TYPES_ERROR_MESSAGE mutations', () => {
|
|
|
|
const errorMessage = 'something went wrong';
|
|
|
|
return testAction(receiveJiraIssueTypesError, errorMessage, state, [
|
|
|
|
{ type: types.SET_IS_LOADING_JIRA_ISSUE_TYPES, payload: false },
|
|
|
|
{ type: types.SET_JIRA_ISSUE_TYPES, payload: [] },
|
|
|
|
{ type: types.SET_JIRA_ISSUE_TYPES_ERROR_MESSAGE, payload: errorMessage },
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
2020-07-28 23:09:34 +05:30
|
|
|
});
|