From 782c31a494faeda9e30ed453953b2be2f80cd5c0 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 29 May 2018 10:35:13 +0100 Subject: added empty state & YAML error state --- spec/javascripts/ide/mock_data.js | 2 ++ .../ide/stores/modules/pipelines/actions_spec.js | 29 ++++++++++++++++------ .../ide/stores/modules/pipelines/mutations_spec.js | 3 ++- 3 files changed, 25 insertions(+), 9 deletions(-) (limited to 'spec/javascripts/ide') diff --git a/spec/javascripts/ide/mock_data.js b/spec/javascripts/ide/mock_data.js index 3359c829c6e..f94c5f19d83 100644 --- a/spec/javascripts/ide/mock_data.js +++ b/spec/javascripts/ide/mock_data.js @@ -20,12 +20,14 @@ export const pipelines = [ ref: 'master', sha: '123', status: 'failed', + commit: { id: '123' }, }, { id: 2, ref: 'master', sha: '213', status: 'success', + commit: { id: '213' }, }, ]; diff --git a/spec/javascripts/ide/stores/modules/pipelines/actions_spec.js b/spec/javascripts/ide/stores/modules/pipelines/actions_spec.js index 273e09f5d12..ee8cae9c199 100644 --- a/spec/javascripts/ide/stores/modules/pipelines/actions_spec.js +++ b/spec/javascripts/ide/stores/modules/pipelines/actions_spec.js @@ -65,15 +65,28 @@ describe('IDE pipelines actions', () => { }); describe('receiveLatestPipelineSuccess', () => { - it('commits pipeline', done => { - testAction( - receiveLatestPipelineSuccess, + const rootGetters = { + lastCommit: { id: '123' }, + }; + let commit; + + beforeEach(() => { + commit = jasmine.createSpy('commit'); + }); + + it('commits pipeline', () => { + receiveLatestPipelineSuccess({ rootGetters, commit }, { pipelines }); + + expect(commit.calls.argsFor(0)).toEqual([ + types.RECEIVE_LASTEST_PIPELINE_SUCCESS, pipelines[0], - mockedState, - [{ type: types.RECEIVE_LASTEST_PIPELINE_SUCCESS, payload: pipelines[0] }], - [], - done, - ); + ]); + }); + + it('commits false when there are no pipelines', () => { + receiveLatestPipelineSuccess({ rootGetters, commit }, { pipelines: [] }); + + expect(commit.calls.argsFor(0)).toEqual([types.RECEIVE_LASTEST_PIPELINE_SUCCESS, false]); }); }); diff --git a/spec/javascripts/ide/stores/modules/pipelines/mutations_spec.js b/spec/javascripts/ide/stores/modules/pipelines/mutations_spec.js index 3e572a66acf..c43d2249af5 100644 --- a/spec/javascripts/ide/stores/modules/pipelines/mutations_spec.js +++ b/spec/javascripts/ide/stores/modules/pipelines/mutations_spec.js @@ -47,13 +47,14 @@ describe('IDE pipelines mutations', () => { path: 'test', commit: { id: '123' }, details: { status: jasmine.any(Object) }, + yamlError: undefined, }); }); it('does not set latest pipeline if pipeline is null', () => { mutations[types.RECEIVE_LASTEST_PIPELINE_SUCCESS](mockedState, null); - expect(mockedState.latestPipeline).toEqual(null); + expect(mockedState.latestPipeline).toEqual(false); }); it('sets stages', () => { -- cgit v1.2.1