diff options
Diffstat (limited to 'spec/frontend/create_cluster/gke_cluster/stores')
3 files changed, 0 insertions, 276 deletions
diff --git a/spec/frontend/create_cluster/gke_cluster/stores/actions_spec.js b/spec/frontend/create_cluster/gke_cluster/stores/actions_spec.js deleted file mode 100644 index c365cb6a9f4..00000000000 --- a/spec/frontend/create_cluster/gke_cluster/stores/actions_spec.js +++ /dev/null @@ -1,141 +0,0 @@ -import testAction from 'helpers/vuex_action_helper'; -import * as actions from '~/create_cluster/gke_cluster/store/actions'; -import * as types from '~/create_cluster/gke_cluster/store/mutation_types'; -import createState from '~/create_cluster/gke_cluster/store/state'; -import gapi from '../helpers'; -import { - selectedProjectMock, - selectedZoneMock, - selectedMachineTypeMock, - gapiProjectsResponseMock, - gapiZonesResponseMock, - gapiMachineTypesResponseMock, -} from '../mock_data'; - -describe('GCP Cluster Dropdown Store Actions', () => { - describe('setProject', () => { - it('should set project', () => { - return testAction( - actions.setProject, - selectedProjectMock, - { selectedProject: {} }, - [{ type: 'SET_PROJECT', payload: selectedProjectMock }], - [], - ); - }); - }); - - describe('setZone', () => { - it('should set zone', () => { - return testAction( - actions.setZone, - selectedZoneMock, - { selectedZone: '' }, - [{ type: 'SET_ZONE', payload: selectedZoneMock }], - [], - ); - }); - }); - - describe('setMachineType', () => { - it('should set machine type', () => { - return testAction( - actions.setMachineType, - selectedMachineTypeMock, - { selectedMachineType: '' }, - [{ type: 'SET_MACHINE_TYPE', payload: selectedMachineTypeMock }], - [], - ); - }); - }); - - describe('setIsValidatingProjectBilling', () => { - it('should set machine type', () => { - return testAction( - actions.setIsValidatingProjectBilling, - true, - { isValidatingProjectBilling: null }, - [{ type: 'SET_IS_VALIDATING_PROJECT_BILLING', payload: true }], - [], - ); - }); - }); - - describe('async fetch methods', () => { - let originalGapi; - - beforeAll(() => { - originalGapi = window.gapi; - window.gapi = gapi; - window.gapiPromise = Promise.resolve(gapi); - }); - - afterAll(() => { - window.gapi = originalGapi; - delete window.gapiPromise; - }); - - describe('fetchProjects', () => { - it('fetches projects from Google API', () => { - const state = createState(); - - return testAction( - actions.fetchProjects, - null, - state, - [{ type: types.SET_PROJECTS, payload: gapiProjectsResponseMock.projects }], - [], - ); - }); - }); - - describe('validateProjectBilling', () => { - it('checks project billing status from Google API', () => { - return testAction( - actions.validateProjectBilling, - true, - { - selectedProject: selectedProjectMock, - selectedZone: '', - selectedMachineType: '', - projectHasBillingEnabled: null, - }, - [ - { type: 'SET_ZONE', payload: '' }, - { type: 'SET_MACHINE_TYPE', payload: '' }, - { type: 'SET_PROJECT_BILLING_STATUS', payload: true }, - ], - [{ type: 'setIsValidatingProjectBilling', payload: false }], - ); - }); - }); - - describe('fetchZones', () => { - it('fetches zones from Google API', () => { - const state = createState(); - - return testAction( - actions.fetchZones, - null, - state, - [{ type: types.SET_ZONES, payload: gapiZonesResponseMock.items }], - [], - ); - }); - }); - - describe('fetchMachineTypes', () => { - it('fetches machine types from Google API', () => { - const state = createState(); - - return testAction( - actions.fetchMachineTypes, - null, - state, - [{ type: types.SET_MACHINE_TYPES, payload: gapiMachineTypesResponseMock.items }], - [], - ); - }); - }); - }); -}); diff --git a/spec/frontend/create_cluster/gke_cluster/stores/getters_spec.js b/spec/frontend/create_cluster/gke_cluster/stores/getters_spec.js deleted file mode 100644 index 39106c3f6ca..00000000000 --- a/spec/frontend/create_cluster/gke_cluster/stores/getters_spec.js +++ /dev/null @@ -1,103 +0,0 @@ -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); - }); - }); - }); -}); diff --git a/spec/frontend/create_cluster/gke_cluster/stores/mutations_spec.js b/spec/frontend/create_cluster/gke_cluster/stores/mutations_spec.js deleted file mode 100644 index 4493d49af43..00000000000 --- a/spec/frontend/create_cluster/gke_cluster/stores/mutations_spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import * as types from '~/create_cluster/gke_cluster/store/mutation_types'; -import mutations from '~/create_cluster/gke_cluster/store/mutations'; -import createState from '~/create_cluster/gke_cluster/store/state'; -import { - gapiProjectsResponseMock, - gapiZonesResponseMock, - gapiMachineTypesResponseMock, -} from '../mock_data'; - -describe('GCP Cluster Dropdown Store Mutations', () => { - describe.each` - mutation | stateProperty | mockData - ${types.SET_PROJECTS} | ${'projects'} | ${gapiProjectsResponseMock.projects} - ${types.SET_ZONES} | ${'zones'} | ${gapiZonesResponseMock.items} - ${types.SET_MACHINE_TYPES} | ${'machineTypes'} | ${gapiMachineTypesResponseMock.items} - ${types.SET_MACHINE_TYPE} | ${'selectedMachineType'} | ${gapiMachineTypesResponseMock.items[0].name} - ${types.SET_ZONE} | ${'selectedZone'} | ${gapiZonesResponseMock.items[0].name} - ${types.SET_PROJECT} | ${'selectedProject'} | ${gapiProjectsResponseMock.projects[0]} - ${types.SET_PROJECT_BILLING_STATUS} | ${'projectHasBillingEnabled'} | ${true} - ${types.SET_IS_VALIDATING_PROJECT_BILLING} | ${'isValidatingProjectBilling'} | ${true} - `('$mutation', ({ mutation, stateProperty, mockData }) => { - it(`should set the mutation payload to the ${stateProperty} state property`, () => { - const state = createState(); - - expect(state[stateProperty]).not.toBe(mockData); - - mutations[mutation](state, mockData); - - expect(state[stateProperty]).toBe(mockData); - }); - }); -}); |