diff --git a/src/common-components/button-question/button-question.spec.js b/src/common-components/button-question/button-question.spec.js
index 67e2f010e..d5608cd62 100644
--- a/src/common-components/button-question/button-question.spec.js
+++ b/src/common-components/button-question/button-question.spec.js
@@ -1,5 +1,6 @@
import { shallowMount } from "@vue/test-utils";
import buttonQuestion from "@/common-components/button-question/button-question";
+import { nextTick } from "vue";
describe("buttonQuestion.vue", () => {
it("Should show overflow classes on fieldset if isOverflowScrollable is true", async () => {
@@ -41,44 +42,32 @@ describe("buttonQuestion.vue", () => {
});
describe("buttonQuestion.vue", () => {
- it("Should trigger event modelValue change on select", async () => {
+ it("Should trigger event modelValue change to new value on when radio button selected", async () => {
// Act
const wrapper = shallowMount(buttonQuestion);
- await wrapper.setData({
- modelValueAnswers: ["Windshield"],
- chosenAnswer: "Windshield"
+ await wrapper.setProps({
+ answers: ["2022", "2021", "2020"],
+ isMultiSelect: false
});
- wrapper.setValue({ answer: wrapper.vm.chosenAnswer });
- await wrapper.vm.$nextTick();
- // Assert
- expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{answer: "Windshield"}]);
- });
-});
-
-describe("buttonQuestion.vue", () => {
- it("Should trigger event modelValue change with an array of string values on select if checked is true and multiple options are chosen", async () => {
- // Act
- const wrapper = shallowMount(buttonQuestion);
- await wrapper.setData({
- modelValueAnswers: ["Windshield", "BackDoor"]
- });
- wrapper.vm.handleCheckedChanged(true);
- // Assert
- expect(typeof wrapper.emitted()["update:modelValue"][0]).toEqual('object');
- });
-});
-
-describe("buttonQuestion.vue", () => {
- it("Should not trigger event modelValue change on select if checked is false", async () => {
- // Act
- const wrapper = shallowMount(buttonQuestion);
- wrapper.setData({
- modelValueAnswers: ["Front-door"]
- })
- const val = {isChecked : false, buttonId: "Front-door"}
+ const val = {isChecked: true, buttonId: "2021", }
wrapper.vm.handleCheckedChanged(val);
// Assert
- expect(wrapper.emitted()["update:modelValue"][0]).toEqual([undefined]);
+ expect(wrapper.emitted()["update:modelValue"][0]).toEqual([["2021"]]);
+ });
+});
+
+describe("buttonQuestion.vue", () => {
+ it("Should add values to array on checkbox click", async () => {
+ // Act
+ const wrapper = shallowMount(buttonQuestion);
+ await wrapper.setProps({
+ modelValue: ["2022", "2021", "2020"],
+ isMultiSelect: true
+ });
+ const val = {isChecked: true, buttonId: "2019", }
+ wrapper.vm.handleCheckedChanged(val);
+ // Assert
+ expect(wrapper.emitted()["update:modelValue"][0]).toEqual([["2022", "2021", "2020", "2019"]]);
});
});
diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue
index 84cee026b..7fff5c238 100644
--- a/src/common-components/button-question/button-question.vue
+++ b/src/common-components/button-question/button-question.vue
@@ -30,7 +30,7 @@
:altText="answer.Name ? answer.Name : answer"
screenReaderOnlyText="(opens new window)"
:colLength="this.answers.length < 3 ? '' : '-4'"
- v-model="selectedValues"
+ :selectedButtonIDs="selectedValues"
data-test="button"
/>
@@ -107,23 +107,23 @@ export default {
}
},
},
- data(){
- return {
- modelValueAnswers: [],
- }
- },
mounted(){
if(Array.isArray(this.answers) && this.answers.length === 1) {
- this.modelValueAnswers.push(typeof(this.answers[0]) === 'object' ? this.answers[0].Name : this.answers[0]);
- this.$emit("update:modelValue", this.modelValueAnswers);
+ const newSelectedValues = this.selectedValues;
+ newSelectedValues.push(typeof(this.answers[0]) === 'object' ? this.answers[0].Name : this.answers[0]);
+ this.selectedValues = newSelectedValues;
}
},
methods: {
handleCheckedChanged(val) {
- // Add or remove item to array of data to emit
- val.isChecked ? this.modelValueAnswers.push(val.buttonId) : this.modelValueAnswers.splice(this.modelValueAnswers.indexOf(val.buttonId), 1);
- const answersToEmit = this.modelValueAnswers.length ? this.modelValueAnswers : undefined;
- this.$emit("update:modelValue", answersToEmit);
+ if(this.isMultiSelect) {
+ // Add or remove item to array of data to emit
+ const newSelectedValues = this.selectedValues;
+ val.isChecked ? newSelectedValues.push(val.buttonId) : newSelectedValues.splice(newSelectedValues.indexOf(val.buttonId), 1);
+ this.selectedValues = newSelectedValues;
+ } else {
+ this.selectedValues = [val.buttonId]
+ }
},
},
components: {
diff --git a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js
index 01f063eef..65434b289 100644
--- a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js
+++ b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js
@@ -41,7 +41,7 @@ describe("damage-location-question.vue", () => {
damageLocationQuestion.methods.initializeComponent.call(wrapper.vm, cmsContent, damageOptions, "car-group");
//Assert
- expect(wrapper.vm.answersToDisplay).toStrictEqual([ { Name: 'car-Windshield' }, { Name: 'car-SideDoor' } ])
+ expect(wrapper.vm.answersToDisplay).toStrictEqual([ { Name: 'car-Windshield' }, { Name: 'car-SideDoor' }, {Name: "car-RearWindow"} ])
});
});
diff --git a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue
index 4000a61c7..c48912ff2 100644
--- a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue
+++ b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue
@@ -3,7 +3,7 @@
-
-
+
+
@@ -60,19 +60,16 @@ export default {
resultMap.cmsContent.FunnelSubHeaderWidget
);
vm.$refs.driverSideOptions.initializeComponent(
- resultMap.cmsContent.DriverSideReplaceOptionsQuestion, resultMap.damageOptions.driverSideOptions.availableReplacementOptions, 'DriverSideReplaceOptionsQuestion'
+ resultMap.cmsContent.DriverSideReplaceOptionsQuestion, resultMap.damageOptions.driverSideOptions.availableReplacementOptions
);
vm.$refs.damageLocation.initializeComponent(
- resultMap.cmsContent.DamageLocationQuestion, resultMap.damageOptions, 'DamageLocationQuestion'
+ resultMap.cmsContent.DamageLocationQuestion, resultMap.damageOptions
);
-
- // for damageOptions and cms content data
- //console.log(resultMap)
});
},
data(){
return {
- damageLocationQuestionData: [],
+ selectedDamageLocations: [],
driverSideOptionsData: [],
}
},
diff --git a/src/layouts/vehicle-make/make-question/make-question.vue b/src/layouts/vehicle-make/make-question/make-question.vue
index 9eeefb7b5..9fb2d6ea1 100644
--- a/src/layouts/vehicle-make/make-question/make-question.vue
+++ b/src/layouts/vehicle-make/make-question/make-question.vue
@@ -33,7 +33,7 @@ export default {
computed: {
selectedValueAsArray: {
get: function() {
- const modelValueAsArray = this.modelValue ? [this.modelValue] : null;
+ const modelValueAsArray = this.modelValue ? [this.modelValue] : [];
return modelValueAsArray;
},
set: function(newValue) {
diff --git a/src/layouts/vehicle-make/vehicle-make.vue b/src/layouts/vehicle-make/vehicle-make.vue
index cd01130b2..023d24023 100644
--- a/src/layouts/vehicle-make/vehicle-make.vue
+++ b/src/layouts/vehicle-make/vehicle-make.vue
@@ -33,7 +33,7 @@ export default {
name: "vehicle-make",
data() {
return {
- selectedMake: String,
+ selectedMake: null,
};
},
computed: {},
diff --git a/src/layouts/vehicle-model/model-question/model-question.vue b/src/layouts/vehicle-model/model-question/model-question.vue
index 3e27198b6..e79b8bafc 100644
--- a/src/layouts/vehicle-model/model-question/model-question.vue
+++ b/src/layouts/vehicle-model/model-question/model-question.vue
@@ -33,7 +33,7 @@ export default {
computed: {
selectedValueAsArray: {
get: function() {
- const modelValueAsArray = this.modelValue ? [this.modelValue] : null;
+ const modelValueAsArray = this.modelValue ? [this.modelValue] : [];
return modelValueAsArray;
},
set: function(newValue) {
diff --git a/src/layouts/vehicle-model/vehicle-model.vue b/src/layouts/vehicle-model/vehicle-model.vue
index 732e27eb0..02de04c3b 100644
--- a/src/layouts/vehicle-model/vehicle-model.vue
+++ b/src/layouts/vehicle-model/vehicle-model.vue
@@ -33,7 +33,7 @@ export default {
name: "vehicle-model",
data() {
return {
- selectedModel: String,
+ selectedModel: null,
};
},
computed: {},
diff --git a/src/layouts/vehicle-style/style-question/style-question.vue b/src/layouts/vehicle-style/style-question/style-question.vue
index 7b316f42a..bfec78571 100644
--- a/src/layouts/vehicle-style/style-question/style-question.vue
+++ b/src/layouts/vehicle-style/style-question/style-question.vue
@@ -33,7 +33,7 @@ export default {
computed: {
selectedValueAsArray: {
get: function() {
- const modelValueAsArray = this.modelValue ? [this.modelValue] : null;
+ const modelValueAsArray = this.modelValue ? [this.modelValue] : [];
return modelValueAsArray;
},
set: function(newValue) {
diff --git a/src/layouts/vehicle-style/vehicle-style.vue b/src/layouts/vehicle-style/vehicle-style.vue
index 8f9954f6d..3009a696a 100644
--- a/src/layouts/vehicle-style/vehicle-style.vue
+++ b/src/layouts/vehicle-style/vehicle-style.vue
@@ -32,7 +32,7 @@ export default {
name: "vehicle-style",
data() {
return {
- selectedStyle: String,
+ selectedStyle: null,
};
},
computed: {},
diff --git a/src/layouts/vehicle-year/vehicle-year.vue b/src/layouts/vehicle-year/vehicle-year.vue
index cd8ee3982..1b10fba92 100644
--- a/src/layouts/vehicle-year/vehicle-year.vue
+++ b/src/layouts/vehicle-year/vehicle-year.vue
@@ -28,7 +28,7 @@ export default {
name: "vehicle-year",
data() {
return {
- selectedYear: String,
+ selectedYear: null,
};
},
computed: {},
diff --git a/src/layouts/vehicle-year/year-question/year-question.spec.js b/src/layouts/vehicle-year/year-question/year-question.spec.js
index fe0852533..3555e6126 100644
--- a/src/layouts/vehicle-year/year-question/year-question.spec.js
+++ b/src/layouts/vehicle-year/year-question/year-question.spec.js
@@ -72,6 +72,7 @@ describe("year-question.vue", () => {
});
});
+
function setupMocks({
modelValueProp = "1900",
cmsQuestionText = "CMS text goes here",
@@ -89,6 +90,7 @@ function setupMocks({
mountOptions.propsData = {
modelValue: modelValueProp,
};
+
const wrapper = shallowMount(yearQuestion, mountOptions);
//Mock CMS content
diff --git a/src/layouts/vehicle-year/year-question/year-question.vue b/src/layouts/vehicle-year/year-question/year-question.vue
index ce79269c6..96d047244 100644
--- a/src/layouts/vehicle-year/year-question/year-question.vue
+++ b/src/layouts/vehicle-year/year-question/year-question.vue
@@ -35,7 +35,7 @@ export default {
computed: {
selectedValueAsArray: {
get: function() {
- const modelValueAsArray = this.modelValue ? [this.modelValue] : null;
+ const modelValueAsArray = this.modelValue ? [this.modelValue] : [];
return modelValueAsArray;
},
set: function(newValue) {
diff --git a/src/ux-components/list-button-horizontal/list-button-horizontal.spec.js b/src/ux-components/list-button-horizontal/list-button-horizontal.spec.js
index c25b169fa..5cbe02e75 100644
--- a/src/ux-components/list-button-horizontal/list-button-horizontal.spec.js
+++ b/src/ux-components/list-button-horizontal/list-button-horizontal.spec.js
@@ -173,4 +173,45 @@ describe("list-button-horizontal.vue", () => {
expect(loader.attributes("style")).toContain("1rem");
});
+
+ it("Should emit button value on click", async () => {
+ // Act
+ const wrapper = shallowMount(listButtonHorizontal, {
+ propsData: {
+ isRadioHorizontal: true,
+ buttonLabel: "Windshield",
+ buttonID: "List Card Checkbox",
+ groupID: "radio-demo-1",
+ groupName: "radio 1",
+ buttonImage: "windshield-damage.svg",
+ isRequired: true,
+ isWide: false,
+ modelValue: ["List Card Checkbox"],
+ },
+ });
+ wrapper.vm.handleCheckChange();
+ // Assert
+ expect(wrapper.emitted()["isCheckedChanged"][0]).toEqual([{buttonId: "List Card Checkbox", isChecked: Boolean}]);
+ });
+
+ it("Should set checkValue data if selectedButtonIDs has value(s)", async () => {
+ // Act
+ const wrapper = shallowMount(listButtonHorizontal, {
+ propsData: {
+ isRadioHorizontal: true,
+ buttonLabel: "Windshield",
+ buttonID: "List Card Checkbox",
+ groupID: "radio-demo-1",
+ groupName: "radio 1",
+ buttonImage: "windshield-damage.svg",
+ isRequired: true,
+ isWide: false,
+ modelValue: ["List Card Checkbox"],
+ isMultiSelect: false,
+ selectedButtonIDs: ["Car-Front"]
+ },
+ });
+ // Assert
+ expect(wrapper.componentVM.checkValue).toEqual("Car-Front");
+ });
});
diff --git a/src/ux-components/list-button-horizontal/list-button-horizontal.vue b/src/ux-components/list-button-horizontal/list-button-horizontal.vue
index db2f9f382..e3e7c3891 100644
--- a/src/ux-components/list-button-horizontal/list-button-horizontal.vue
+++ b/src/ux-components/list-button-horizontal/list-button-horizontal.vue
@@ -12,6 +12,7 @@
:aria-required="isRequired"
:data-focus-target="groupName"
v-model="checkValue"
+ @change="handleCheckChange"
/>