diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-27 03:07:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-27 03:07:50 +0300 |
commit | 431b84710e87a649de02d398568804f820e3b0fe (patch) | |
tree | 9cbc49a395615412c152d2bffa9255a3b37fafed /spec/frontend/search/store/actions_spec.js | |
parent | e04b8c1e60649802ae4249dae7fa7aaf3f0a83c7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/search/store/actions_spec.js')
-rw-r--r-- | spec/frontend/search/store/actions_spec.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/frontend/search/store/actions_spec.js b/spec/frontend/search/store/actions_spec.js index 3d19b27ff86..041679e9139 100644 --- a/spec/frontend/search/store/actions_spec.js +++ b/spec/frontend/search/store/actions_spec.js @@ -27,6 +27,9 @@ import { MOCK_NAVIGATION_DATA, MOCK_NAVIGATION_ACTION_MUTATION, MOCK_ENDPOINT_RESPONSE, + MOCK_RECEIVE_AGGREGATIONS_SUCCESS_MUTATION, + MOCK_RECEIVE_AGGREGATIONS_ERROR_MUTATION, + MOCK_AGGREGATIONS, } from '../mock_data'; jest.mock('~/flash'); @@ -295,4 +298,30 @@ describe('Global Search Store Actions', () => { }); }); }); + + describe.each` + action | axiosMock | type | expectedMutations | errorLogs + ${actions.fetchLanguageAggregation} | ${{ method: 'onGet', code: 200 }} | ${'success'} | ${MOCK_RECEIVE_AGGREGATIONS_SUCCESS_MUTATION} | ${0} + ${actions.fetchLanguageAggregation} | ${{ method: 'onPut', code: 0 }} | ${'error'} | ${MOCK_RECEIVE_AGGREGATIONS_ERROR_MUTATION} | ${1} + ${actions.fetchLanguageAggregation} | ${{ method: 'onGet', code: 500 }} | ${'error'} | ${MOCK_RECEIVE_AGGREGATIONS_ERROR_MUTATION} | ${1} + `('fetchLanguageAggregation', ({ action, axiosMock, type, expectedMutations, errorLogs }) => { + describe(`on ${type}`, () => { + beforeEach(() => { + if (axiosMock.method) { + mock[axiosMock.method]().reply( + axiosMock.code, + axiosMock.code === 200 ? MOCK_AGGREGATIONS : [], + ); + } + }); + + it(`should ${type === 'error' ? 'NOT ' : ''}dispatch ${ + type === 'error' ? '' : 'the correct ' + }mutations`, () => { + return testAction({ action, state, expectedMutations }).then(() => { + expect(logger.logError).toHaveBeenCalledTimes(errorLogs); + }); + }); + }); + }); }); |