diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 21:08:52 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 21:08:52 +0000 |
commit | d5d3c03598df712550acf0c6463a61c6e7dcc19e (patch) | |
tree | d0fdf0f9cd6df46aea6ed16b6556f44055efb642 /spec/frontend/error_tracking/store/actions_spec.js | |
parent | 0434f38ef1dce4fe640fe1e4542235746ceb943c (diff) | |
download | gitlab-ce-d5d3c03598df712550acf0c6463a61c6e7dcc19e.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/error_tracking/store/actions_spec.js')
-rw-r--r-- | spec/frontend/error_tracking/store/actions_spec.js | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/spec/frontend/error_tracking/store/actions_spec.js b/spec/frontend/error_tracking/store/actions_spec.js index 8bc53d94345..e4a895902b3 100644 --- a/spec/frontend/error_tracking/store/actions_spec.js +++ b/spec/frontend/error_tracking/store/actions_spec.js @@ -10,6 +10,8 @@ jest.mock('~/flash.js'); jest.mock('~/lib/utils/url_utility'); let mock; +const commit = jest.fn(); +const dispatch = jest.fn().mockResolvedValue(); describe('Sentry common store actions', () => { beforeEach(() => { @@ -20,26 +22,22 @@ describe('Sentry common store actions', () => { mock.restore(); createFlash.mockClear(); }); + const endpoint = '123/stacktrace'; + const redirectUrl = '/list'; + const status = 'resolved'; + const params = { endpoint, redirectUrl, status }; describe('updateStatus', () => { - const endpoint = '123/stacktrace'; - const redirectUrl = '/list'; - const status = 'resolved'; - it('should handle successful status update', done => { mock.onPut().reply(200, {}); testAction( actions.updateStatus, - { endpoint, redirectUrl, status }, + params, {}, [ { - payload: true, - type: types.SET_UPDATING_RESOLVE_STATUS, - }, - { - payload: false, - type: 'SET_UPDATING_RESOLVE_STATUS', + payload: 'resolved', + type: types.SET_ERROR_STATUS, }, ], [], @@ -52,27 +50,29 @@ describe('Sentry common store actions', () => { it('should handle unsuccessful status update', done => { mock.onPut().reply(400, {}); - testAction( - actions.updateStatus, - { endpoint, redirectUrl, status }, - {}, - [ - { - payload: true, - type: types.SET_UPDATING_RESOLVE_STATUS, - }, - { - payload: false, - type: types.SET_UPDATING_RESOLVE_STATUS, - }, - ], - [], - () => { - expect(visitUrl).not.toHaveBeenCalled(); - expect(createFlash).toHaveBeenCalledTimes(1); - done(); - }, - ); + testAction(actions.updateStatus, params, {}, [], [], () => { + expect(visitUrl).not.toHaveBeenCalled(); + expect(createFlash).toHaveBeenCalledTimes(1); + done(); + }); }); }); + + describe('updateResolveStatus', () => { + it('handles status update', () => + actions.updateResolveStatus({ commit, dispatch }, params).then(() => { + expect(commit).toHaveBeenCalledWith(types.SET_UPDATING_RESOLVE_STATUS, true); + expect(commit).toHaveBeenCalledWith(types.SET_UPDATING_RESOLVE_STATUS, false); + expect(dispatch).toHaveBeenCalledWith('updateStatus', params); + })); + }); + + describe('updateIgnoreStatus', () => { + it('handles status update', () => + actions.updateIgnoreStatus({ commit, dispatch }, params).then(() => { + expect(commit).toHaveBeenCalledWith(types.SET_UPDATING_IGNORE_STATUS, true); + expect(commit).toHaveBeenCalledWith(types.SET_UPDATING_IGNORE_STATUS, false); + expect(dispatch).toHaveBeenCalledWith('updateStatus', params); + })); + }); }); |