diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-23 06:08:32 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-23 06:08:32 +0000 |
commit | 0f8c2334f0e57a22bf10e4485c17f856289e4fb4 (patch) | |
tree | 6cf14307d353a1ac89cc5f7e022c110329dd9282 /spec/frontend | |
parent | ccaa94488202341c25d24f6f16a70a9f658fc742 (diff) | |
download | gitlab-ce-0f8c2334f0e57a22bf10e4485c17f856289e4fb4.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/error_tracking/store/details/actions_spec.js | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/spec/frontend/error_tracking/store/details/actions_spec.js b/spec/frontend/error_tracking/store/details/actions_spec.js index 129760bb705..fa37886f176 100644 --- a/spec/frontend/error_tracking/store/details/actions_spec.js +++ b/spec/frontend/error_tracking/store/details/actions_spec.js @@ -4,27 +4,33 @@ import axios from '~/lib/utils/axios_utils'; import createFlash from '~/flash'; import * as actions from '~/error_tracking/store/details/actions'; import * as types from '~/error_tracking/store/details/mutation_types'; +import Poll from '~/lib/utils/poll'; + +let mockedAdapter; +let mockedRestart; jest.mock('~/flash.js'); jest.mock('~/lib/utils/url_utility'); -let mock; - describe('Sentry error details store actions', () => { beforeEach(() => { - mock = new MockAdapter(axios); + mockedAdapter = new MockAdapter(axios); }); afterEach(() => { - mock.restore(); + mockedAdapter.restore(); createFlash.mockClear(); + if (mockedRestart) { + mockedRestart.mockRestore(); + mockedRestart = null; + } }); describe('startPollingDetails', () => { const endpoint = '123/details'; it('should commit SET_ERROR with received response', done => { const payload = { error: { id: 1 } }; - mock.onGet().reply(200, payload); + mockedAdapter.onGet().reply(200, payload); testAction( actions.startPollingDetails, { endpoint }, @@ -41,7 +47,7 @@ describe('Sentry error details store actions', () => { }); it('should show flash on API error', done => { - mock.onGet().reply(400); + mockedAdapter.onGet().reply(400); testAction( actions.startPollingDetails, @@ -55,13 +61,23 @@ describe('Sentry error details store actions', () => { }, ); }); + + it('should not restart polling when receiving an empty 204 response', done => { + mockedRestart = jest.spyOn(Poll.prototype, 'restart'); + mockedAdapter.onGet().reply(204); + + testAction(actions.startPollingDetails, { endpoint }, {}, [], [], () => { + expect(mockedRestart).toHaveBeenCalledTimes(0); + done(); + }); + }); }); describe('startPollingStacktrace', () => { const endpoint = '123/stacktrace'; it('should commit SET_ERROR with received response', done => { const payload = { error: [1, 2, 3] }; - mock.onGet().reply(200, payload); + mockedAdapter.onGet().reply(200, payload); testAction( actions.startPollingStacktrace, { endpoint }, @@ -78,7 +94,7 @@ describe('Sentry error details store actions', () => { }); it('should show flash on API error', done => { - mock.onGet().reply(400); + mockedAdapter.onGet().reply(400); testAction( actions.startPollingStacktrace, @@ -92,5 +108,16 @@ describe('Sentry error details store actions', () => { }, ); }); + + it('should not restart polling when receiving an empty 204 response', done => { + mockedRestart = jest.spyOn(Poll.prototype, 'restart'); + mockedAdapter.onGet().reply(204); + + testAction(actions.startPollingStacktrace, { endpoint }, {}, [], [], () => { + mockedRestart = jest.spyOn(Poll.prototype, 'restart'); + expect(mockedRestart).toHaveBeenCalledTimes(0); + done(); + }); + }); }); }); |