diff options
Diffstat (limited to 'spec/frontend/create_cluster/store')
-rw-r--r-- | spec/frontend/create_cluster/store/cluster_dropdown/actions_spec.js | 95 | ||||
-rw-r--r-- | spec/frontend/create_cluster/store/cluster_dropdown/mutations_spec.js | 36 |
2 files changed, 0 insertions, 131 deletions
diff --git a/spec/frontend/create_cluster/store/cluster_dropdown/actions_spec.js b/spec/frontend/create_cluster/store/cluster_dropdown/actions_spec.js deleted file mode 100644 index c0e8b11cf1e..00000000000 --- a/spec/frontend/create_cluster/store/cluster_dropdown/actions_spec.js +++ /dev/null @@ -1,95 +0,0 @@ -import testAction from 'helpers/vuex_action_helper'; - -import actionsFactory from '~/create_cluster/store/cluster_dropdown/actions'; -import * as types from '~/create_cluster/store/cluster_dropdown/mutation_types'; -import createState from '~/create_cluster/store/cluster_dropdown/state'; - -describe('Cluster dropdown Store Actions', () => { - const items = [{ name: 'item 1' }]; - let fetchFn; - let actions; - - beforeEach(() => { - fetchFn = jest.fn(); - actions = actionsFactory(fetchFn); - }); - - describe('fetchItems', () => { - describe('on success', () => { - beforeEach(() => { - fetchFn.mockResolvedValueOnce(items); - actions = actionsFactory(fetchFn); - }); - - it('dispatches success with received items', () => - testAction( - actions.fetchItems, - null, - createState(), - [], - [ - { type: 'requestItems' }, - { - type: 'receiveItemsSuccess', - payload: { items }, - }, - ], - )); - }); - - describe('on failure', () => { - const error = new Error('Could not fetch items'); - - beforeEach(() => { - fetchFn.mockRejectedValueOnce(error); - }); - - it('dispatches success with received items', () => - testAction( - actions.fetchItems, - null, - createState(), - [], - [ - { type: 'requestItems' }, - { - type: 'receiveItemsError', - payload: { error }, - }, - ], - )); - }); - }); - - describe('requestItems', () => { - it(`commits ${types.REQUEST_ITEMS} mutation`, () => - testAction(actions.requestItems, null, createState(), [{ type: types.REQUEST_ITEMS }])); - }); - - describe('receiveItemsSuccess', () => { - it(`commits ${types.RECEIVE_ITEMS_SUCCESS} mutation`, () => - testAction(actions.receiveItemsSuccess, { items }, createState(), [ - { - type: types.RECEIVE_ITEMS_SUCCESS, - payload: { - items, - }, - }, - ])); - }); - - describe('receiveItemsError', () => { - it(`commits ${types.RECEIVE_ITEMS_ERROR} mutation`, () => { - const error = new Error('Error fetching items'); - - testAction(actions.receiveItemsError, { error }, createState(), [ - { - type: types.RECEIVE_ITEMS_ERROR, - payload: { - error, - }, - }, - ]); - }); - }); -}); diff --git a/spec/frontend/create_cluster/store/cluster_dropdown/mutations_spec.js b/spec/frontend/create_cluster/store/cluster_dropdown/mutations_spec.js deleted file mode 100644 index 197fcfc2600..00000000000 --- a/spec/frontend/create_cluster/store/cluster_dropdown/mutations_spec.js +++ /dev/null @@ -1,36 +0,0 @@ -import { - REQUEST_ITEMS, - RECEIVE_ITEMS_SUCCESS, - RECEIVE_ITEMS_ERROR, -} from '~/create_cluster/store/cluster_dropdown/mutation_types'; -import mutations from '~/create_cluster/store/cluster_dropdown/mutations'; -import createState from '~/create_cluster/store/cluster_dropdown/state'; - -describe('Cluster dropdown store mutations', () => { - let state; - let emptyPayload; - let items; - let error; - - beforeEach(() => { - emptyPayload = {}; - items = [{ name: 'item 1' }]; - error = new Error('could not load error'); - state = createState(); - }); - - it.each` - mutation | mutatedProperty | payload | expectedValue | expectedValueDescription - ${REQUEST_ITEMS} | ${'isLoadingItems'} | ${emptyPayload} | ${true} | ${true} - ${REQUEST_ITEMS} | ${'loadingItemsError'} | ${emptyPayload} | ${null} | ${null} - ${RECEIVE_ITEMS_SUCCESS} | ${'isLoadingItems'} | ${{ items }} | ${false} | ${false} - ${RECEIVE_ITEMS_SUCCESS} | ${'items'} | ${{ items }} | ${items} | ${'items payload'} - ${RECEIVE_ITEMS_ERROR} | ${'isLoadingItems'} | ${{ error }} | ${false} | ${false} - ${RECEIVE_ITEMS_ERROR} | ${'error'} | ${{ error }} | ${error} | ${'received error object'} - `(`$mutation sets $mutatedProperty to $expectedValueDescription`, (data) => { - const { mutation, mutatedProperty, payload, expectedValue } = data; - - mutations[mutation](state, payload); - expect(state[mutatedProperty]).toBe(expectedValue); - }); -}); |