diff options
author | Phil Hughes <me@iamphill.com> | 2018-07-02 15:42:54 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-07-03 16:09:36 +0100 |
commit | 9c8d80796d4fc6fb528c53f0f5681b7a7fd3917b (patch) | |
tree | ef2bca05bc64836a3465420cceb720b9a5feff92 /spec | |
parent | b2ff2e8d926ac102a6e29e8ba4bfdcba2177c045 (diff) | |
download | gitlab-ce-9c8d80796d4fc6fb528c53f0f5681b7a7fd3917b.tar.gz |
karma fixes
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/ide/stores/modules/merge_requests/actions_spec.js | 28 | ||||
-rw-r--r-- | spec/javascripts/ide/stores/modules/pipelines/actions_spec.js | 79 |
2 files changed, 63 insertions, 44 deletions
diff --git a/spec/javascripts/ide/stores/modules/merge_requests/actions_spec.js b/spec/javascripts/ide/stores/modules/merge_requests/actions_spec.js index fa4c18931e5..d21f33eaf6d 100644 --- a/spec/javascripts/ide/stores/modules/merge_requests/actions_spec.js +++ b/spec/javascripts/ide/stores/modules/merge_requests/actions_spec.js @@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; import state from '~/ide/stores/modules/merge_requests/state'; import * as types from '~/ide/stores/modules/merge_requests/mutation_types'; -import actions, { +import { requestMergeRequests, receiveMergeRequestsError, receiveMergeRequestsSuccess, @@ -41,28 +41,26 @@ describe('IDE merge requests actions', () => { }); describe('receiveMergeRequestsError', () => { - let flashSpy; - - beforeEach(() => { - flashSpy = spyOnDependency(actions, 'flash'); - }); - it('should should commit error', done => { testAction( receiveMergeRequestsError, - 'created', + { type: 'created', search: '' }, mockedState, [{ type: types.RECEIVE_MERGE_REQUESTS_ERROR, payload: 'created' }], - [], + [ + { + type: 'setErrorMessage', + payload: { + text: 'Error loading merge requests.', + action: jasmine.any(Function), + actionText: 'Please try again', + actionPayload: { type: 'created', search: '' }, + }, + }, + ], done, ); }); - - it('creates flash message', () => { - receiveMergeRequestsError({ commit() {} }, 'created'); - - expect(flashSpy).toHaveBeenCalled(); - }); }); describe('receiveMergeRequestsSuccess', () => { diff --git a/spec/javascripts/ide/stores/modules/pipelines/actions_spec.js b/spec/javascripts/ide/stores/modules/pipelines/actions_spec.js index f47e69d6e5b..f76564bbe6f 100644 --- a/spec/javascripts/ide/stores/modules/pipelines/actions_spec.js +++ b/spec/javascripts/ide/stores/modules/pipelines/actions_spec.js @@ -1,7 +1,7 @@ import Visibility from 'visibilityjs'; import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; -import actions, { +import { requestLatestPipeline, receiveLatestPipelineError, receiveLatestPipelineSuccess, @@ -59,7 +59,7 @@ describe('IDE pipelines actions', () => { it('commits error', done => { testAction( receiveLatestPipelineError, - null, + { response: { status: 404 } }, mockedState, [{ type: types.RECEIVE_LASTEST_PIPELINE_ERROR }], [{ type: 'stopPipelinePolling' }], @@ -67,12 +67,26 @@ describe('IDE pipelines actions', () => { ); }); - it('creates flash message', () => { - const flashSpy = spyOnDependency(actions, 'flash'); - - receiveLatestPipelineError({ commit() {}, dispatch() {} }); - - expect(flashSpy).toHaveBeenCalled(); + it('dispatches setErrorMessage is not 404', done => { + testAction( + receiveLatestPipelineError, + { response: { status: 500 } }, + mockedState, + [{ type: types.RECEIVE_LASTEST_PIPELINE_ERROR }], + [ + { + type: 'setErrorMessage', + payload: { + text: 'An error occured whilst fetching the latest pipline.', + action: jasmine.any(Function), + actionText: 'Please try again', + actionPayload: null, + }, + }, + { type: 'stopPipelinePolling' }, + ], + done, + ); }); }); @@ -181,7 +195,10 @@ describe('IDE pipelines actions', () => { new Promise(resolve => requestAnimationFrame(resolve)) .then(() => { - expect(dispatch.calls.argsFor(1)).toEqual(['receiveLatestPipelineError']); + expect(dispatch.calls.argsFor(1)).toEqual([ + 'receiveLatestPipelineError', + jasmine.anything(), + ]); }) .then(done) .catch(done.fail); @@ -199,21 +216,23 @@ describe('IDE pipelines actions', () => { it('commits error', done => { testAction( receiveJobsError, - 1, + { id: 1 }, mockedState, [{ type: types.RECEIVE_JOBS_ERROR, payload: 1 }], - [], + [ + { + type: 'setErrorMessage', + payload: { + text: 'An error occured whilst loading the pipelines jobs.', + action: jasmine.anything(), + actionText: 'Please try again', + actionPayload: { id: 1 }, + }, + }, + ], done, ); }); - - it('creates flash message', () => { - const flashSpy = spyOnDependency(actions, 'flash'); - - receiveJobsError({ commit() {} }, 1); - - expect(flashSpy).toHaveBeenCalled(); - }); }); describe('receiveJobsSuccess', () => { @@ -268,7 +287,7 @@ describe('IDE pipelines actions', () => { [], [ { type: 'requestJobs', payload: stage.id }, - { type: 'receiveJobsError', payload: stage.id }, + { type: 'receiveJobsError', payload: stage }, ], done, ); @@ -337,18 +356,20 @@ describe('IDE pipelines actions', () => { null, mockedState, [{ type: types.RECEIVE_JOB_TRACE_ERROR }], - [], + [ + { + type: 'setErrorMessage', + payload: { + text: 'An error occured whilst fetching the job trace.', + action: jasmine.any(Function), + actionText: 'Please try again', + actionPayload: null, + }, + }, + ], done, ); }); - - it('creates flash message', () => { - const flashSpy = spyOnDependency(actions, 'flash'); - - receiveJobTraceError({ commit() {} }); - - expect(flashSpy).toHaveBeenCalled(); - }); }); describe('receiveJobTraceSuccess', () => { |