diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/frontend/pipelines/stores/pipeline_store_spec.js | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/frontend/pipelines/stores/pipeline_store_spec.js')
-rw-r--r-- | spec/frontend/pipelines/stores/pipeline_store_spec.js | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/spec/frontend/pipelines/stores/pipeline_store_spec.js b/spec/frontend/pipelines/stores/pipeline_store_spec.js new file mode 100644 index 00000000000..68d438109b3 --- /dev/null +++ b/spec/frontend/pipelines/stores/pipeline_store_spec.js @@ -0,0 +1,135 @@ +import PipelineStore from '~/pipelines/stores/pipeline_store'; +import LinkedPipelines from '../linked_pipelines_mock.json'; + +describe('EE Pipeline store', () => { + let store; + let data; + + beforeEach(() => { + store = new PipelineStore(); + data = { ...LinkedPipelines }; + + store.storePipeline(data); + }); + + describe('storePipeline', () => { + describe('triggered_by', () => { + it('sets triggered_by as an array', () => { + expect(store.state.pipeline.triggered_by.length).toEqual(1); + }); + + it('adds isExpanding & isLoading keys set to false', () => { + expect(store.state.pipeline.triggered_by[0].isExpanded).toEqual(false); + expect(store.state.pipeline.triggered_by[0].isLoading).toEqual(false); + }); + + it('parses nested triggered_by', () => { + expect(store.state.pipeline.triggered_by[0].triggered_by.length).toEqual(1); + expect(store.state.pipeline.triggered_by[0].triggered_by[0].isExpanded).toEqual(false); + expect(store.state.pipeline.triggered_by[0].triggered_by[0].isLoading).toEqual(false); + }); + }); + + describe('triggered', () => { + it('adds isExpanding & isLoading keys set to false for each triggered pipeline', () => { + store.state.pipeline.triggered.forEach(pipeline => { + expect(pipeline.isExpanded).toEqual(false); + expect(pipeline.isLoading).toEqual(false); + }); + }); + + it('parses nested triggered pipelines', () => { + store.state.pipeline.triggered[1].triggered.forEach(pipeline => { + expect(pipeline.isExpanded).toEqual(false); + expect(pipeline.isLoading).toEqual(false); + }); + }); + }); + }); + + describe('resetTriggeredByPipeline', () => { + it('closes the pipeline & nested ones', () => { + store.state.pipeline.triggered_by[0].isExpanded = true; + store.state.pipeline.triggered_by[0].triggered_by[0].isExpanded = true; + + store.resetTriggeredByPipeline(store.state.pipeline, store.state.pipeline.triggered_by[0]); + + expect(store.state.pipeline.triggered_by[0].isExpanded).toEqual(false); + expect(store.state.pipeline.triggered_by[0].triggered_by[0].isExpanded).toEqual(false); + }); + }); + + describe('openTriggeredByPipeline', () => { + it('opens the given pipeline', () => { + store.openTriggeredByPipeline(store.state.pipeline, store.state.pipeline.triggered_by[0]); + + expect(store.state.pipeline.triggered_by[0].isExpanded).toEqual(true); + }); + }); + + describe('closeTriggeredByPipeline', () => { + it('closes the given pipeline', () => { + // open it first + store.openTriggeredByPipeline(store.state.pipeline, store.state.pipeline.triggered_by[0]); + + store.closeTriggeredByPipeline(store.state.pipeline, store.state.pipeline.triggered_by[0]); + + expect(store.state.pipeline.triggered_by[0].isExpanded).toEqual(false); + }); + }); + + describe('resetTriggeredPipelines', () => { + it('closes the pipeline & nested ones', () => { + store.state.pipeline.triggered[0].isExpanded = true; + store.state.pipeline.triggered[0].triggered[0].isExpanded = true; + + store.resetTriggeredPipelines(store.state.pipeline, store.state.pipeline.triggered[0]); + + expect(store.state.pipeline.triggered[0].isExpanded).toEqual(false); + expect(store.state.pipeline.triggered[0].triggered[0].isExpanded).toEqual(false); + }); + }); + + describe('openTriggeredPipeline', () => { + it('opens the given pipeline', () => { + store.openTriggeredPipeline(store.state.pipeline, store.state.pipeline.triggered[0]); + + expect(store.state.pipeline.triggered[0].isExpanded).toEqual(true); + }); + }); + + describe('closeTriggeredPipeline', () => { + it('closes the given pipeline', () => { + // open it first + store.openTriggeredPipeline(store.state.pipeline, store.state.pipeline.triggered[0]); + + store.closeTriggeredPipeline(store.state.pipeline, store.state.pipeline.triggered[0]); + + expect(store.state.pipeline.triggered[0].isExpanded).toEqual(false); + }); + }); + + describe('toggleLoading', () => { + it('toggles the isLoading property for the given pipeline', () => { + store.toggleLoading(store.state.pipeline.triggered[0]); + + expect(store.state.pipeline.triggered[0].isLoading).toEqual(true); + }); + }); + + describe('addExpandedPipelineToRequestData', () => { + it('pushes the given id to expandedPipelines array', () => { + store.addExpandedPipelineToRequestData('213231'); + + expect(store.state.expandedPipelines).toEqual(['213231']); + }); + }); + + describe('removeExpandedPipelineToRequestData', () => { + it('pushes the given id to expandedPipelines array', () => { + store.removeExpandedPipelineToRequestData('213231'); + + expect(store.state.expandedPipelines).toEqual([]); + }); + }); +}); |