BigW Consortium Gitlab

Commit f86f9450 by Dennis Tang

removed „fetched“ prefix from mutation and state

parent 4f001a3a
...@@ -42,8 +42,7 @@ export default { ...@@ -42,8 +42,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(['selectedProject', 'selectedZone', 'selectedMachineType']), ...mapState(['selectedProject', 'selectedZone', 'selectedMachineType', 'machineTypes']),
...mapState({ machineTypes: 'fetchedMachineTypes' }),
...mapGetters(['hasProject', 'hasZone', 'hasMachineType']), ...mapGetters(['hasProject', 'hasZone', 'hasMachineType']),
isDisabled() { isDisabled() {
return !this.selectedProject || !this.selectedZone; return !this.selectedProject || !this.selectedZone;
......
...@@ -45,8 +45,7 @@ export default { ...@@ -45,8 +45,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(['selectedProject']), ...mapState(['selectedProject', 'projects']),
...mapState({ projects: 'fetchedProjects' }),
...mapGetters(['hasProject']), ...mapGetters(['hasProject']),
hasOneProject() { hasOneProject() {
return this.projects.length === 1; return this.projects.length === 1;
......
...@@ -42,8 +42,7 @@ export default { ...@@ -42,8 +42,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(['selectedProject', 'selectedZone']), ...mapState(['selectedProject', 'selectedZone', 'zones']),
...mapState({ zones: 'fetchedZones' }),
...mapGetters(['hasProject']), ...mapGetters(['hasProject']),
isDisabled() { isDisabled() {
return !this.hasProject; return !this.hasProject;
......
...@@ -29,7 +29,7 @@ export const getProjects = ({ commit }) => ...@@ -29,7 +29,7 @@ export const getProjects = ({ commit }) =>
return request.then( return request.then(
resp => { resp => {
commit(types.SET_FETCHED_PROJECTS, resp.result.projects); commit(types.SET_PROJECTS, resp.result.projects);
resolve(); resolve();
}, },
...@@ -60,7 +60,7 @@ export const getZones = ({ commit, state }) => ...@@ -60,7 +60,7 @@ export const getZones = ({ commit, state }) =>
return request.then( return request.then(
resp => { resp => {
commit(types.SET_FETCHED_ZONES, resp.result.items); commit(types.SET_ZONES, resp.result.items);
resolve(); resolve();
}, },
...@@ -90,7 +90,7 @@ export const getMachineTypes = ({ commit, state }) => ...@@ -90,7 +90,7 @@ export const getMachineTypes = ({ commit, state }) =>
return request.then( return request.then(
resp => { resp => {
commit(types.SET_FETCHED_MACHINE_TYPES, resp.result.items); commit(types.SET_MACHINE_TYPES, resp.result.items);
resolve(); resolve();
}, },
......
...@@ -17,8 +17,8 @@ export default new Vuex.Store({ ...@@ -17,8 +17,8 @@ export default new Vuex.Store({
}, },
selectedZone: '', selectedZone: '',
selectedMachineType: '', selectedMachineType: '',
fetchedProjects: [], projects: [],
fetchedZones: [], zones: [],
fetchedMachineTypes: [], machineTypes: [],
}, },
}); });
export const SET_PROJECT = 'SET_PROJECT'; export const SET_PROJECT = 'SET_PROJECT';
export const SET_ZONE = 'SET_ZONE'; export const SET_ZONE = 'SET_ZONE';
export const SET_MACHINE_TYPE = 'SET_MACHINE_TYPE'; export const SET_MACHINE_TYPE = 'SET_MACHINE_TYPE';
export const SET_FETCHED_PROJECTS = 'SET_FETCHED_PROJECTS'; export const SET_PROJECTS = 'SET_PROJECTS';
export const SET_FETCHED_ZONES = 'SET_FETCHED_ZONES'; export const SET_ZONES = 'SET_ZONES';
export const SET_FETCHED_MACHINE_TYPES = 'SET_FETCHED_MACHINE_TYPES'; export const SET_MACHINE_TYPES = 'SET_MACHINE_TYPES';
...@@ -10,13 +10,13 @@ export default { ...@@ -10,13 +10,13 @@ export default {
[types.SET_MACHINE_TYPE](state, selectedMachineType) { [types.SET_MACHINE_TYPE](state, selectedMachineType) {
Object.assign(state, { selectedMachineType }); Object.assign(state, { selectedMachineType });
}, },
[types.SET_FETCHED_PROJECTS](state, fetchedProjects) { [types.SET_PROJECTS](state, projects) {
Object.assign(state, { fetchedProjects }); Object.assign(state, { projects });
}, },
[types.SET_FETCHED_ZONES](state, fetchedZones) { [types.SET_ZONES](state, zones) {
Object.assign(state, { fetchedZones }); Object.assign(state, { zones });
}, },
[types.SET_FETCHED_MACHINE_TYPES](state, fetchedMachineTypes) { [types.SET_MACHINE_TYPES](state, machineTypes) {
Object.assign(state, { fetchedMachineTypes }); Object.assign(state, { machineTypes });
}, },
}; };
...@@ -3,8 +3,8 @@ import GkeMachineTypeDropdown from '~/projects/gke_cluster_dropdowns/components/ ...@@ -3,8 +3,8 @@ import GkeMachineTypeDropdown from '~/projects/gke_cluster_dropdowns/components/
import { import {
SET_PROJECT, SET_PROJECT,
SET_ZONE, SET_ZONE,
SET_FETCHED_ZONES, SET_ZONES,
SET_FETCHED_MACHINE_TYPES, SET_MACHINE_TYPES,
} from '~/projects/gke_cluster_dropdowns/stores/mutation_types'; } from '~/projects/gke_cluster_dropdowns/stores/mutation_types';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
...@@ -84,7 +84,7 @@ describe('GkeMachineTypeDropdown', () => { ...@@ -84,7 +84,7 @@ describe('GkeMachineTypeDropdown', () => {
describe('form input', () => { describe('form input', () => {
it('reflects new value when dropdown item is clicked', done => { it('reflects new value when dropdown item is clicked', done => {
expect(vm.$el.querySelector('input').value).toBe(''); expect(vm.$el.querySelector('input').value).toBe('');
vm.$store.commit(SET_FETCHED_MACHINE_TYPES, gapiMachineTypesResponseMock.items); vm.$store.commit(SET_MACHINE_TYPES, gapiMachineTypesResponseMock.items);
vm.$nextTick(() => { vm.$nextTick(() => {
vm.$el.querySelector('.dropdown-content button').click(); vm.$el.querySelector('.dropdown-content button').click();
......
import Vue from 'vue'; import Vue from 'vue';
import GkeProjectIdDropdown from '~/projects/gke_cluster_dropdowns/components/gke_project_id_dropdown.vue'; import GkeProjectIdDropdown from '~/projects/gke_cluster_dropdowns/components/gke_project_id_dropdown.vue';
import { SET_FETCHED_PROJECTS } from '~/projects/gke_cluster_dropdowns/stores/mutation_types'; import { SET_PROJECTS } from '~/projects/gke_cluster_dropdowns/stores/mutation_types';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
import { resetStore } from '../helpers'; import { resetStore } from '../helpers';
...@@ -64,7 +64,7 @@ describe('GkeProjectIdDropdown', () => { ...@@ -64,7 +64,7 @@ describe('GkeProjectIdDropdown', () => {
it('returns empty toggle text', done => { it('returns empty toggle text', done => {
vm.$nextTick(() => { vm.$nextTick(() => {
vm.$store.commit(SET_FETCHED_PROJECTS, []); vm.$store.commit(SET_PROJECTS, []);
vm.setProject(emptyProjectMock); vm.setProject(emptyProjectMock);
vm.$nextTick(() => { vm.$nextTick(() => {
......
import Vue from 'vue'; import Vue from 'vue';
import GkeZoneDropdown from '~/projects/gke_cluster_dropdowns/components/gke_zone_dropdown.vue'; import GkeZoneDropdown from '~/projects/gke_cluster_dropdowns/components/gke_zone_dropdown.vue';
import { import { SET_PROJECT, SET_ZONES } from '~/projects/gke_cluster_dropdowns/stores/mutation_types';
SET_PROJECT,
SET_FETCHED_ZONES,
} from '~/projects/gke_cluster_dropdowns/stores/mutation_types';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
import { resetStore } from '../helpers'; import { resetStore } from '../helpers';
...@@ -67,7 +64,7 @@ describe('GkeZoneDropdown', () => { ...@@ -67,7 +64,7 @@ describe('GkeZoneDropdown', () => {
describe('selectItem', () => { describe('selectItem', () => {
it('reflects new value when dropdown item is clicked', done => { it('reflects new value when dropdown item is clicked', done => {
expect(vm.$el.querySelector('input').value).toBe(''); expect(vm.$el.querySelector('input').value).toBe('');
vm.$store.commit(SET_FETCHED_ZONES, gapiZonesResponseMock.items); vm.$store.commit(SET_ZONES, gapiZonesResponseMock.items);
vm.$nextTick(() => { vm.$nextTick(() => {
vm.$el.querySelector('.dropdown-content button').click(); vm.$el.querySelector('.dropdown-content button').click();
......
...@@ -13,9 +13,9 @@ export const resetStore = store => { ...@@ -13,9 +13,9 @@ export const resetStore = store => {
}, },
selectedZone: '', selectedZone: '',
selectedMachineType: '', selectedMachineType: '',
fetchedProjects: [], projects: [],
fetchedZones: [], zones: [],
fetchedMachineTypes: [], machineTypes: [],
}); });
}; };
......
...@@ -56,8 +56,8 @@ describe('GCP Cluster Dropdown Store Actions', () => { ...@@ -56,8 +56,8 @@ describe('GCP Cluster Dropdown Store Actions', () => {
store store
.dispatch('getProjects') .dispatch('getProjects')
.then(() => { .then(() => {
expect(store.state.fetchedProjects[0].projectId).toEqual(selectedProjectMock.projectId); expect(store.state.projects[0].projectId).toEqual(selectedProjectMock.projectId);
expect(store.state.fetchedProjects[0].name).toEqual(selectedProjectMock.name); expect(store.state.projects[0].name).toEqual(selectedProjectMock.name);
done(); done();
}) })
...@@ -70,7 +70,7 @@ describe('GCP Cluster Dropdown Store Actions', () => { ...@@ -70,7 +70,7 @@ describe('GCP Cluster Dropdown Store Actions', () => {
store store
.dispatch('getZones') .dispatch('getZones')
.then(() => { .then(() => {
expect(store.state.fetchedZones[0].name).toEqual(selectedZoneMock); expect(store.state.zones[0].name).toEqual(selectedZoneMock);
done(); done();
}) })
...@@ -83,7 +83,7 @@ describe('GCP Cluster Dropdown Store Actions', () => { ...@@ -83,7 +83,7 @@ describe('GCP Cluster Dropdown Store Actions', () => {
store store
.dispatch('getMachineTypes') .dispatch('getMachineTypes')
.then(() => { .then(() => {
expect(store.state.fetchedMachineTypes[0].name).toEqual(selectedMachineTypeMock); expect(store.state.machineTypes[0].name).toEqual(selectedMachineTypeMock);
done(); done();
}) })
......
...@@ -52,45 +52,45 @@ describe('GCP Cluster Dropdown Store Mutations', () => { ...@@ -52,45 +52,45 @@ describe('GCP Cluster Dropdown Store Mutations', () => {
}); });
}); });
describe('SET_FETCHED_PROJECTS', () => { describe('SET_PROJECTS', () => {
it('should set Google API Projects response as fetchedProjects', () => { it('should set Google API Projects response as projects', () => {
const state = { const state = {
fetchedProjects: [], projects: [],
}; };
expect(state.fetchedProjects.length).toEqual(0); expect(state.projects.length).toEqual(0);
mutations.SET_FETCHED_PROJECTS(state, gapiProjectsResponseMock.projects); mutations.SET_PROJECTS(state, gapiProjectsResponseMock.projects);
expect(state.fetchedProjects.length).toEqual(gapiProjectsResponseMock.projects.length); expect(state.projects.length).toEqual(gapiProjectsResponseMock.projects.length);
}); });
}); });
describe('SET_FETCHED_ZONES', () => { describe('SET_ZONES', () => {
it('should set Google API Zones response as fetchedZones', () => { it('should set Google API Zones response as zones', () => {
const state = { const state = {
fetchedZones: [], zones: [],
}; };
expect(state.fetchedZones.length).toEqual(0); expect(state.zones.length).toEqual(0);
mutations.SET_FETCHED_ZONES(state, gapiZonesResponseMock.items); mutations.SET_ZONES(state, gapiZonesResponseMock.items);
expect(state.fetchedZones.length).toEqual(gapiZonesResponseMock.items.length); expect(state.zones.length).toEqual(gapiZonesResponseMock.items.length);
}); });
}); });
describe('SET_FETCHED_MACHINE_TYPES', () => { describe('SET_MACHINE_TYPES', () => {
it('should set Google API Machine Types response as fetchedMachineTypes', () => { it('should set Google API Machine Types response as machineTypes', () => {
const state = { const state = {
fetchedMachineTypes: [], machineTypes: [],
}; };
expect(state.fetchedMachineTypes.length).toEqual(0); expect(state.machineTypes.length).toEqual(0);
mutations.SET_FETCHED_MACHINE_TYPES(state, gapiMachineTypesResponseMock.items); mutations.SET_MACHINE_TYPES(state, gapiMachineTypesResponseMock.items);
expect(state.fetchedMachineTypes.length).toEqual(gapiMachineTypesResponseMock.items.length); expect(state.machineTypes.length).toEqual(gapiMachineTypesResponseMock.items.length);
}); });
}); });
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment