diff options
author | Dennis Tang <dtang@gitlab.com> | 2018-05-23 20:53:19 +0300 |
---|---|---|
committer | Dennis Tang <dtang@gitlab.com> | 2018-05-23 20:53:19 +0300 |
commit | 303af892befc1b8d3408dde45cbf6c33d0e97d09 (patch) | |
tree | f556503096c519bfd9805e26b7809acf0ee360be /spec/javascripts/projects | |
parent | b394cc31e29a153d1d4c93da75e666fa610a8434 (diff) |
update mutation spec to use real store
Diffstat (limited to 'spec/javascripts/projects')
-rw-r--r-- | spec/javascripts/projects/gke_cluster_dropdowns/stores/mutations_spec.js | 72 |
1 files changed, 26 insertions, 46 deletions
diff --git a/spec/javascripts/projects/gke_cluster_dropdowns/stores/mutations_spec.js b/spec/javascripts/projects/gke_cluster_dropdowns/stores/mutations_spec.js index 7cef492305b..7f8c4f314e4 100644 --- a/spec/javascripts/projects/gke_cluster_dropdowns/stores/mutations_spec.js +++ b/spec/javascripts/projects/gke_cluster_dropdowns/stores/mutations_spec.js @@ -1,4 +1,5 @@ -import mutations from '~/projects/gke_cluster_dropdowns/store/mutations'; +import { createStore } from '~/projects/gke_cluster_dropdowns/store'; +import * as types from '~/projects/gke_cluster_dropdowns/store/mutation_types'; import { selectedProjectMock, selectedZoneMock, @@ -9,99 +10,78 @@ import { } from '../mock_data'; describe('GCP Cluster Dropdown Store Mutations', () => { + let store; + + beforeEach(() => { + store = createStore(); + }); + describe('SET_PROJECT', () => { it('should set GCP project as selectedProject', () => { - const state = { - selectedProject: { - projectId: '', - name: '', - }, - }; const projectToSelect = gapiProjectsResponseMock.projects[0]; - mutations.SET_PROJECT(state, projectToSelect); + store.commit(types.SET_PROJECT, projectToSelect); - expect(state.selectedProject.projectId).toEqual(selectedProjectMock.projectId); - expect(state.selectedProject.name).toEqual(selectedProjectMock.name); + expect(store.state.selectedProject.projectId).toEqual(selectedProjectMock.projectId); + expect(store.state.selectedProject.name).toEqual(selectedProjectMock.name); }); }); describe('SET_PROJECT_BILLING_STATUS', () => { it('should set project billing status', () => { - const state = { - projectHasBillingEnabled: null, - }; - mutations.SET_PROJECT_BILLING_STATUS(state, true); + store.commit(types.SET_PROJECT_BILLING_STATUS, true); - expect(state.projectHasBillingEnabled).toBeTruthy(); + expect(store.state.projectHasBillingEnabled).toBeTruthy(); }); }); describe('SET_ZONE', () => { it('should set GCP zone as selectedZone', () => { - const state = { - selectedZone: '', - }; const zoneToSelect = gapiZonesResponseMock.items[0].name; - mutations.SET_ZONE(state, zoneToSelect); + store.commit(types.SET_ZONE, zoneToSelect); - expect(state.selectedZone).toEqual(selectedZoneMock); + expect(store.state.selectedZone).toEqual(selectedZoneMock); }); }); describe('SET_MACHINE_TYPE', () => { it('should set GCP machine type as selectedMachineType', () => { - const state = { - selectedMachineType: '', - }; const machineTypeToSelect = gapiMachineTypesResponseMock.items[0].name; - mutations.SET_MACHINE_TYPE(state, machineTypeToSelect); + store.commit(types.SET_MACHINE_TYPE, machineTypeToSelect); - expect(state.selectedMachineType).toEqual(selectedMachineTypeMock); + expect(store.state.selectedMachineType).toEqual(selectedMachineTypeMock); }); }); describe('SET_PROJECTS', () => { it('should set Google API Projects response as projects', () => { - const state = { - projects: [], - }; + expect(store.state.projects.length).toEqual(0); - expect(state.projects.length).toEqual(0); + store.commit(types.SET_PROJECTS, gapiProjectsResponseMock.projects); - mutations.SET_PROJECTS(state, gapiProjectsResponseMock.projects); - - expect(state.projects.length).toEqual(gapiProjectsResponseMock.projects.length); + expect(store.state.projects.length).toEqual(gapiProjectsResponseMock.projects.length); }); }); describe('SET_ZONES', () => { it('should set Google API Zones response as zones', () => { - const state = { - zones: [], - }; - - expect(state.zones.length).toEqual(0); + expect(store.state.zones.length).toEqual(0); - mutations.SET_ZONES(state, gapiZonesResponseMock.items); + store.commit(types.SET_ZONES, gapiZonesResponseMock.items); - expect(state.zones.length).toEqual(gapiZonesResponseMock.items.length); + expect(store.state.zones.length).toEqual(gapiZonesResponseMock.items.length); }); }); describe('SET_MACHINE_TYPES', () => { it('should set Google API Machine Types response as machineTypes', () => { - const state = { - machineTypes: [], - }; - - expect(state.machineTypes.length).toEqual(0); + expect(store.state.machineTypes.length).toEqual(0); - mutations.SET_MACHINE_TYPES(state, gapiMachineTypesResponseMock.items); + store.commit(types.SET_MACHINE_TYPES, gapiMachineTypesResponseMock.items); - expect(state.machineTypes.length).toEqual(gapiMachineTypesResponseMock.items.length); + expect(store.state.machineTypes.length).toEqual(gapiMachineTypesResponseMock.items.length); }); }); }); |