diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-03-29 17:29:57 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-03-29 17:29:57 +0100 |
commit | d3ab245a5be3c840c0a6e7de1a6488a7f8170115 (patch) | |
tree | 4fcc8fe4643c539b4ca221e32e05206839a2510c /spec | |
parent | 5e9f0bead17d7cb0a336a22a6c8200418ca0fef9 (diff) | |
download | gitlab-ce-d3ab245a5be3c840c0a6e7de1a6488a7f8170115.tar.gz |
Adds tests that were only in EE
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/environments/environments_store_spec.js | 89 |
1 files changed, 68 insertions, 21 deletions
diff --git a/spec/javascripts/environments/environments_store_spec.js b/spec/javascripts/environments/environments_store_spec.js index 55181621e8d..f617c4bdffe 100644 --- a/spec/javascripts/environments/environments_store_spec.js +++ b/spec/javascripts/environments/environments_store_spec.js @@ -31,27 +31,49 @@ describe('Store', () => { expect(store.state.stoppedCounter).toEqual(2); }); - it('should store pagination information', () => { - const pagination = { - 'X-nExt-pAge': '2', - 'X-page': '1', - 'X-Per-Page': '1', - 'X-Prev-Page': '2', - 'X-TOTAL': '37', - 'X-Total-Pages': '2', - }; - - const expectedResult = { - perPage: 1, - page: 1, - total: 37, - totalPages: 2, - nextPage: 2, - previousPage: 2, - }; - - store.setPagination(pagination); - expect(store.state.paginationInformation).toEqual(expectedResult); + describe('store environments', () => { + it('should store environments', () => { + store.storeEnvironments(serverData); + expect(store.state.environments.length).toEqual(serverData.length); + }); + + it('should add folder keys when environment is a folder', () => { + const environment = { + name: 'bar', + size: 3, + id: 2, + }; + + store.storeEnvironments([environment]); + expect(store.state.environments[0].isFolder).toEqual(true); + expect(store.state.environments[0].folderName).toEqual('bar'); + }); + + it('should extract content of `latest` key when provided', () => { + const environment = { + name: 'bar', + size: 3, + id: 2, + latest: { + last_deployment: {}, + isStoppable: true, + }, + }; + + store.storeEnvironments([environment]); + expect(store.state.environments[0].last_deployment).toEqual({}); + expect(store.state.environments[0].isStoppable).toEqual(true); + }); + + it('should store latest.name when the environment is not a folder', () => { + store.storeEnvironments(serverData); + expect(store.state.environments[0].name).toEqual(serverData[0].latest.name); + }); + + it('should store root level name when environment is a folder', () => { + store.storeEnvironments(serverData); + expect(store.state.environments[1].folderName).toEqual(serverData[1].name); + }); }); describe('toggleFolder', () => { @@ -76,4 +98,29 @@ describe('Store', () => { expect(store.state.environments[1].children[0].isChildren).toEqual(true); }); }); + + describe('store pagination', () => { + it('should store normalized and integer pagination information', () => { + const pagination = { + 'X-nExt-pAge': '2', + 'X-page': '1', + 'X-Per-Page': '1', + 'X-Prev-Page': '2', + 'X-TOTAL': '37', + 'X-Total-Pages': '2', + }; + + const expectedResult = { + perPage: 1, + page: 1, + total: 37, + totalPages: 2, + nextPage: 2, + previousPage: 2, + }; + + store.setPagination(pagination); + expect(store.state.paginationInformation).toEqual(expectedResult); + }); + }); }); |