CSR-666 Import store, cleanup
This commit is contained in:
parent
fd9267593b
commit
79072bb3b5
3 changed files with 13 additions and 21 deletions
|
|
@ -1,13 +1,15 @@
|
||||||
|
import store from "@/store";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
hasSettingEqualTo(settingName, settingValue) {
|
hasSettingEqualTo(settingName, settingValue) {
|
||||||
return this.$store.getters.experimentSettings[settingName] === settingValue;
|
return store.getters.experimentSettings[settingName] === settingValue;
|
||||||
},
|
},
|
||||||
hasSetting(settingName) {
|
hasSetting(settingName) {
|
||||||
return this.$store.getters.experimentSettings.hasOwnProperty(settingName);
|
return store.getters.experimentSettings.hasOwnProperty(settingName);
|
||||||
},
|
},
|
||||||
getSettingValue(settingName) {
|
getSettingValue(settingName) {
|
||||||
return this.hasSetting(settingName) ? this.$store.getters.experimentSettings[settingName] : null;
|
return this.hasSetting(settingName) ? store.getters.experimentSettings[settingName] : null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import experimentMixin from "@/mixins/experiment-mixin";
|
import experimentMixin from "@/mixins/experiment-mixin";
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
|
import store from "@/store";
|
||||||
|
|
||||||
describe("experiment-mixin", () => {
|
describe("experiment-mixin", () => {
|
||||||
describe("hasSettingEqualTo", () => {
|
describe("hasSettingEqualTo", () => {
|
||||||
|
|
@ -121,22 +122,20 @@ describe("experiment-mixin", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupMocks({ experimentSettings }) {
|
function setupMocks({ experimentSettings }) {
|
||||||
const defaultExperimentSettings = experimentSettings ?? {
|
const mocks = getMountOptions({});
|
||||||
|
|
||||||
|
const testExperimentSettings = {
|
||||||
"Setting1": "Value1",
|
"Setting1": "Value1",
|
||||||
"Setting2": "Value2",
|
"Setting2": "Value2",
|
||||||
"Setting3": "Value3",
|
"Setting3": "Value3",
|
||||||
"Setting4": "Value1",
|
"Setting4": "Value1",
|
||||||
"Setting5": "Value2",
|
"Setting5": "Value2",
|
||||||
"Setting6": "Value3"
|
"Setting6": "Value3"
|
||||||
}
|
};
|
||||||
|
|
||||||
const mocks = getMountOptions({
|
store.getters = {
|
||||||
store: {
|
experimentSettings: experimentSettings ?? testExperimentSettings
|
||||||
getters: {
|
};
|
||||||
experimentSettings: defaultExperimentSettings
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const mockComponent = {
|
const mockComponent = {
|
||||||
template: "<div></div>",
|
template: "<div></div>",
|
||||||
|
|
|
||||||
|
|
@ -895,23 +895,14 @@ function setupMocks({ partsOrQuestions = [] }) {
|
||||||
router: {
|
router: {
|
||||||
navigate: jest.fn()
|
navigate: jest.fn()
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const mockVinComponent = {
|
const mockVinComponent = {
|
||||||
components: { loadingModal },
|
components: { loadingModal },
|
||||||
template: '<loadingModal ref="loadingModal" />',
|
template: '<loadingModal ref="loadingModal" />',
|
||||||
// render() {
|
|
||||||
// return '<div ref="loadingModal"></div>'
|
|
||||||
// },
|
|
||||||
mixins: [vinPagesMixin, baseMixin.baseMixin]
|
mixins: [vinPagesMixin, baseMixin.baseMixin]
|
||||||
};
|
};
|
||||||
|
|
||||||
// const mockVinComponent = Vue.component("mockcomponent", {
|
|
||||||
// template: '<loadingModal ref="loadingModal" />',
|
|
||||||
// mixins: [vinPagesMixin, baseMixin.baseMixin]
|
|
||||||
// })
|
|
||||||
|
|
||||||
const wrapper = shallowMount(mockVinComponent, mocks);
|
const wrapper = shallowMount(mockVinComponent, mocks);
|
||||||
|
|
||||||
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue