diff options
Diffstat (limited to 'spec/frontend/environments/environments_store_spec.js')
-rw-r--r-- | spec/frontend/environments/environments_store_spec.js | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/spec/frontend/environments/environments_store_spec.js b/spec/frontend/environments/environments_store_spec.js index 8abdbcbbe54..4a07281353f 100644 --- a/spec/frontend/environments/environments_store_spec.js +++ b/spec/frontend/environments/environments_store_spec.js @@ -1,5 +1,5 @@ import Store from '~/environments/stores/environments_store'; -import { environmentsList, serverData } from './mock_data'; +import { environmentsList, serverData, deployBoardMockData } from './mock_data'; describe('Store', () => { let store; @@ -160,4 +160,58 @@ describe('Store', () => { expect(store.getOpenFolders()[0]).toEqual(store.state.environments[1]); }); }); + + it('should store a non folder environment with deploy board if rollout_status key is provided', () => { + const environment = { + name: 'foo', + size: 1, + latest: { + id: 1, + rollout_status: deployBoardMockData, + }, + }; + + store.storeEnvironments([environment]); + + expect(store.state.environments[0].hasDeployBoard).toEqual(true); + expect(store.state.environments[0].isDeployBoardVisible).toEqual(true); + expect(store.state.environments[0].deployBoardData).toEqual(deployBoardMockData); + }); + + describe('deploy boards', () => { + beforeEach(() => { + const environment = { + name: 'foo', + size: 1, + latest: { + id: 1, + }, + rollout_status: deployBoardMockData, + }; + + store.storeEnvironments([environment]); + }); + + it('should toggle deploy board property for given environment id', () => { + store.toggleDeployBoard(1); + + expect(store.state.environments[0].isDeployBoardVisible).toEqual(false); + }); + + it('should keep deploy board data when updating environments', () => { + expect(store.state.environments[0].deployBoardData).toEqual(deployBoardMockData); + + const environment = { + name: 'foo', + size: 1, + latest: { + id: 1, + }, + rollout_status: deployBoardMockData, + }; + store.storeEnvironments([environment]); + + expect(store.state.environments[0].deployBoardData).toEqual(deployBoardMockData); + }); + }); }); |