diff options
Diffstat (limited to 'spec/frontend/vue_shared/components/sidebar/labels_select_widget/store')
-rw-r--r-- | spec/frontend/vue_shared/components/sidebar/labels_select_widget/store/actions_spec.js | 88 | ||||
-rw-r--r-- | spec/frontend/vue_shared/components/sidebar/labels_select_widget/store/mutations_spec.js | 52 |
2 files changed, 0 insertions, 140 deletions
diff --git a/spec/frontend/vue_shared/components/sidebar/labels_select_widget/store/actions_spec.js b/spec/frontend/vue_shared/components/sidebar/labels_select_widget/store/actions_spec.js index 27de7de2411..ee905410ffa 100644 --- a/spec/frontend/vue_shared/components/sidebar/labels_select_widget/store/actions_spec.js +++ b/spec/frontend/vue_shared/components/sidebar/labels_select_widget/store/actions_spec.js @@ -1,8 +1,4 @@ -import MockAdapter from 'axios-mock-adapter'; - import testAction from 'helpers/vuex_action_helper'; -import createFlash from '~/flash'; -import axios from '~/lib/utils/axios_utils'; import * as actions from '~/vue_shared/components/sidebar/labels_select_widget/store/actions'; import * as types from '~/vue_shared/components/sidebar/labels_select_widget/store/mutation_types'; import defaultState from '~/vue_shared/components/sidebar/labels_select_widget/store/state'; @@ -72,90 +68,6 @@ describe('LabelsSelect Actions', () => { }); }); - describe('requestLabels', () => { - it('sets value of `state.labelsFetchInProgress` to `true`', (done) => { - testAction(actions.requestLabels, {}, state, [{ type: types.REQUEST_LABELS }], [], done); - }); - }); - - describe('receiveLabelsSuccess', () => { - it('sets provided labels to `state.labels`', (done) => { - const labels = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }]; - - testAction( - actions.receiveLabelsSuccess, - labels, - state, - [{ type: types.RECEIVE_SET_LABELS_SUCCESS, payload: labels }], - [], - done, - ); - }); - }); - - describe('receiveLabelsFailure', () => { - it('sets value `state.labelsFetchInProgress` to `false`', (done) => { - testAction( - actions.receiveLabelsFailure, - {}, - state, - [{ type: types.RECEIVE_SET_LABELS_FAILURE }], - [], - done, - ); - }); - - it('shows flash error', () => { - actions.receiveLabelsFailure({ commit: () => {} }); - - expect(createFlash).toHaveBeenCalledWith({ message: 'Error fetching labels.' }); - }); - }); - - describe('fetchLabels', () => { - let mock; - - beforeEach(() => { - mock = new MockAdapter(axios); - state.labelsFetchPath = 'labels.json'; - }); - - afterEach(() => { - mock.restore(); - }); - - describe('on success', () => { - it('dispatches `requestLabels` & `receiveLabelsSuccess` actions', (done) => { - const labels = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }]; - mock.onGet(/labels.json/).replyOnce(200, labels); - - testAction( - actions.fetchLabels, - {}, - state, - [], - [{ type: 'requestLabels' }, { type: 'receiveLabelsSuccess', payload: labels }], - done, - ); - }); - }); - - describe('on failure', () => { - it('dispatches `requestLabels` & `receiveLabelsFailure` actions', (done) => { - mock.onGet(/labels.json/).replyOnce(500, {}); - - testAction( - actions.fetchLabels, - {}, - state, - [], - [{ type: 'requestLabels' }, { type: 'receiveLabelsFailure' }], - done, - ); - }); - }); - }); - describe('updateSelectedLabels', () => { it('updates `state.labels` based on provided `labels` param', (done) => { const labels = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }]; diff --git a/spec/frontend/vue_shared/components/sidebar/labels_select_widget/store/mutations_spec.js b/spec/frontend/vue_shared/components/sidebar/labels_select_widget/store/mutations_spec.js index 9e965cb33e8..1f0e0eee420 100644 --- a/spec/frontend/vue_shared/components/sidebar/labels_select_widget/store/mutations_spec.js +++ b/spec/frontend/vue_shared/components/sidebar/labels_select_widget/store/mutations_spec.js @@ -67,58 +67,6 @@ describe('LabelsSelect Mutations', () => { }); }); - describe(`${types.REQUEST_LABELS}`, () => { - it('sets value of `state.labelsFetchInProgress` to true', () => { - const state = { - labelsFetchInProgress: false, - }; - mutations[types.REQUEST_LABELS](state); - - expect(state.labelsFetchInProgress).toBe(true); - }); - }); - - describe(`${types.RECEIVE_SET_LABELS_SUCCESS}`, () => { - const selectedLabels = [{ id: 2 }, { id: 4 }]; - const labels = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }]; - - it('sets value of `state.labelsFetchInProgress` to false', () => { - const state = { - selectedLabels, - labelsFetchInProgress: true, - }; - mutations[types.RECEIVE_SET_LABELS_SUCCESS](state, labels); - - expect(state.labelsFetchInProgress).toBe(false); - }); - - it('sets provided `labels` to `state.labels` along with `set` prop based on `state.selectedLabels`', () => { - const selectedLabelIds = selectedLabels.map((label) => label.id); - const state = { - selectedLabels, - labelsFetchInProgress: true, - }; - mutations[types.RECEIVE_SET_LABELS_SUCCESS](state, labels); - - state.labels.forEach((label) => { - if (selectedLabelIds.includes(label.id)) { - expect(label.set).toBe(true); - } - }); - }); - }); - - describe(`${types.RECEIVE_SET_LABELS_FAILURE}`, () => { - it('sets value of `state.labelsFetchInProgress` to false', () => { - const state = { - labelsFetchInProgress: true, - }; - mutations[types.RECEIVE_SET_LABELS_FAILURE](state); - - expect(state.labelsFetchInProgress).toBe(false); - }); - }); - describe(`${types.UPDATE_SELECTED_LABELS}`, () => { let labels; |