diff options
Diffstat (limited to 'spec/frontend/integrations/edit/store')
4 files changed, 67 insertions, 5 deletions
diff --git a/spec/frontend/integrations/edit/store/actions_spec.js b/spec/frontend/integrations/edit/store/actions_spec.js index 1ff881c265d..e2f4c138ece 100644 --- a/spec/frontend/integrations/edit/store/actions_spec.js +++ b/spec/frontend/integrations/edit/store/actions_spec.js @@ -1,6 +1,4 @@ import testAction from 'helpers/vuex_action_helper'; -import { refreshCurrentPage } from '~/lib/utils/url_utility'; -import createState from '~/integrations/edit/store/state'; import { setOverride, setIsSaving, @@ -9,8 +7,13 @@ import { requestResetIntegration, receiveResetIntegrationSuccess, receiveResetIntegrationError, + requestJiraIssueTypes, + receiveJiraIssueTypesSuccess, + receiveJiraIssueTypesError, } from '~/integrations/edit/store/actions'; import * as types from '~/integrations/edit/store/mutation_types'; +import createState from '~/integrations/edit/store/state'; +import { refreshCurrentPage } from '~/lib/utils/url_utility'; jest.mock('~/lib/utils/url_utility'); @@ -70,4 +73,34 @@ describe('Integration form store actions', () => { ]); }); }); + + 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 }, + ]); + }); + }); }); diff --git a/spec/frontend/integrations/edit/store/getters_spec.js b/spec/frontend/integrations/edit/store/getters_spec.js index 7d4532a1059..ad7a887dff2 100644 --- a/spec/frontend/integrations/edit/store/getters_spec.js +++ b/spec/frontend/integrations/edit/store/getters_spec.js @@ -4,9 +4,9 @@ import { isDisabled, propsSource, } from '~/integrations/edit/store/getters'; -import createState from '~/integrations/edit/store/state'; -import mutations from '~/integrations/edit/store/mutations'; import * as types from '~/integrations/edit/store/mutation_types'; +import mutations from '~/integrations/edit/store/mutations'; +import createState from '~/integrations/edit/store/state'; import { mockIntegrationProps } from '../mock_data'; describe('Integration form store getters', () => { diff --git a/spec/frontend/integrations/edit/store/mutations_spec.js b/spec/frontend/integrations/edit/store/mutations_spec.js index 81f39adb87f..18faa2f6bba 100644 --- a/spec/frontend/integrations/edit/store/mutations_spec.js +++ b/spec/frontend/integrations/edit/store/mutations_spec.js @@ -1,6 +1,6 @@ +import * as types from '~/integrations/edit/store/mutation_types'; import mutations from '~/integrations/edit/store/mutations'; import createState from '~/integrations/edit/store/state'; -import * as types from '~/integrations/edit/store/mutation_types'; describe('Integration form store mutations', () => { let state; @@ -56,4 +56,30 @@ describe('Integration form store mutations', () => { expect(state.isResetting).toBe(false); }); }); + + describe(`${types.SET_JIRA_ISSUE_TYPES}`, () => { + it('sets jiraIssueTypes', () => { + const jiraIssueTypes = ['issue', 'epic']; + mutations[types.SET_JIRA_ISSUE_TYPES](state, jiraIssueTypes); + + expect(state.jiraIssueTypes).toBe(jiraIssueTypes); + }); + }); + + describe(`${types.SET_IS_LOADING_JIRA_ISSUE_TYPES}`, () => { + it.each([true, false])('sets isLoadingJiraIssueTypes to "%s"', (isLoading) => { + mutations[types.SET_IS_LOADING_JIRA_ISSUE_TYPES](state, isLoading); + + expect(state.isLoadingJiraIssueTypes).toBe(isLoading); + }); + }); + + describe(`${types.SET_JIRA_ISSUE_TYPES_ERROR_MESSAGE}`, () => { + it('sets loadingJiraIssueTypesErrorMessage', () => { + const errorMessage = 'something went wrong'; + mutations[types.SET_JIRA_ISSUE_TYPES_ERROR_MESSAGE](state, errorMessage); + + expect(state.loadingJiraIssueTypesErrorMessage).toBe(errorMessage); + }); + }); }); diff --git a/spec/frontend/integrations/edit/store/state_spec.js b/spec/frontend/integrations/edit/store/state_spec.js index 4d0f4a1da71..6cd84836395 100644 --- a/spec/frontend/integrations/edit/store/state_spec.js +++ b/spec/frontend/integrations/edit/store/state_spec.js @@ -9,6 +9,9 @@ describe('Integration form state factory', () => { isTesting: false, isResetting: false, override: false, + isLoadingJiraIssueTypes: false, + jiraIssueTypes: [], + loadingJiraIssueTypesErrorMessage: '', }); }); |