diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-20 12:09:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-20 12:09:13 +0300 |
commit | 1ac794623a8be5dee111716a44dd04ff708f3541 (patch) | |
tree | 6c18f9fbe0bd9978bd3e8d9b083d3a0ca180686e /spec/frontend | |
parent | 5247fe0bef72fa922841a79d5dbefb47d95112fa (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/create_cluster/gke_cluster/stores/getters_spec.js | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/spec/frontend/create_cluster/gke_cluster/stores/getters_spec.js b/spec/frontend/create_cluster/gke_cluster/stores/getters_spec.js new file mode 100644 index 00000000000..39106c3f6ca --- /dev/null +++ b/spec/frontend/create_cluster/gke_cluster/stores/getters_spec.js @@ -0,0 +1,103 @@ +import { + hasProject, + hasZone, + hasMachineType, + hasValidData, +} from '~/create_cluster/gke_cluster/store/getters'; +import { selectedProjectMock, selectedZoneMock, selectedMachineTypeMock } from '../mock_data'; + +describe('GCP Cluster Dropdown Store Getters', () => { + let state; + + describe('valid states', () => { + beforeEach(() => { + state = { + projectHasBillingEnabled: true, + selectedProject: selectedProjectMock, + selectedZone: selectedZoneMock, + selectedMachineType: selectedMachineTypeMock, + }; + }); + + describe('hasProject', () => { + it('should return true when project is selected', () => { + expect(hasProject(state)).toEqual(true); + }); + }); + + describe('hasZone', () => { + it('should return true when zone is selected', () => { + expect(hasZone(state)).toEqual(true); + }); + }); + + describe('hasMachineType', () => { + it('should return true when machine type is selected', () => { + expect(hasMachineType(state)).toEqual(true); + }); + }); + + describe('hasValidData', () => { + it('should return true when a project, zone and machine type are selected', () => { + expect(hasValidData(state, { hasZone: true, hasMachineType: true })).toEqual(true); + }); + }); + }); + + describe('invalid states', () => { + beforeEach(() => { + state = { + selectedProject: { + projectId: '', + name: '', + }, + selectedZone: '', + selectedMachineType: '', + }; + }); + + describe('hasProject', () => { + it('should return false when project is not selected', () => { + expect(hasProject(state)).toEqual(false); + }); + }); + + describe('hasZone', () => { + it('should return false when zone is not selected', () => { + expect(hasZone(state)).toEqual(false); + }); + }); + + describe('hasMachineType', () => { + it('should return false when machine type is not selected', () => { + expect(hasMachineType(state)).toEqual(false); + }); + }); + + describe('hasValidData', () => { + let getters; + + beforeEach(() => { + getters = { hasZone: true, hasMachineType: true }; + }); + + it('should return false when project is not billable', () => { + state.projectHasBillingEnabled = false; + + expect(hasValidData(state, getters)).toEqual(false); + }); + + it('should return false when zone is not selected', () => { + getters.hasZone = false; + + expect(hasValidData(state, getters)).toEqual(false); + }); + + it('should return false when machine type is not selected', () => { + getters.hasMachineType = false; + + expect(hasValidData(state, getters)).toEqual(false); + }); + }); + }); +}); |