Merge branch 'develop' into feature/CSR-203

This commit is contained in:
Adam Caouette 2021-12-07 14:52:03 -05:00
commit f5c87af4a2
7 changed files with 23 additions and 28 deletions

View file

@ -2,15 +2,15 @@ import { shallowMount } from "@vue/test-utils";
import radioQuestion from "@/common-components/radio-question/radio-question"; import radioQuestion from "@/common-components/radio-question/radio-question";
describe("radioQuestion.vue", () => { describe("radioQuestion.vue", () => {
it("Should render the 'questionText' prop value as a span value for the radio question and the 'answer' values should render as text values for radio components.", () => { it("Should render the 'questionText' prop value as a span value for the radio question and the 'answer' values should render as text values for radio components.", async () => {
// Act // Act
const wrapper = shallowMount(radioQuestion, { const wrapper = shallowMount(radioQuestion)
propsData: { await wrapper.setProps({
questionText: "Question Text", questionText: "Question Text",
answers: ["2023", "2022", "2021"], answers: ["2023", "2022", "2021"],
modelValue: '2020' modelValue: "2020"
},
}); });
wrapper.vm.chooseAnswer("2021");
// Assert // Assert
expect(wrapper.find(".needed_car_info-text").text()).toEqual( expect(wrapper.find(".needed_car_info-text").text()).toEqual(

View file

@ -33,7 +33,6 @@ export default {
answers: Array, answers: Array,
modelValue: String modelValue: String
}, },
emits: ['update:modelValue'],
methods: { methods: {
chooseAnswer(answer) { chooseAnswer(answer) {
this.$emit('update:modelValue', answer); this.$emit('update:modelValue', answer);

View file

@ -23,7 +23,14 @@ describe("vehicle-year.vue", () => {
SiteHeaderWidget: [{ "LogoImage": "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite-logo.svg?sfvrsn=45e7ed06_3" }], SiteHeaderWidget: [{ "LogoImage": "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite-logo.svg?sfvrsn=45e7ed06_3" }],
isCmsContentReady: true, isCmsContentReady: true,
}, },
getVehicleYear: [2023, 2022, 2021] getVehicleYear: [2023, 2022, 2021],
store: {
commit: jest.fn(),
year: null
},
router: {
push: jest.fn()
}
} }
// our router information needed. // our router information needed.
@ -40,6 +47,7 @@ describe("vehicle-year.vue", () => {
// Act // Act
const wrapper = shallowMount(vehicleYear, mountOptions); const wrapper = shallowMount(vehicleYear, mountOptions);
wrapper.vm.$options.watch.selectedYear.call(wrapper.vm);
// Call our beforeRouteEnter on the component. // Call our beforeRouteEnter on the component.
// This passes (c) => c(wrapper.vm) so that next can be called and our // This passes (c) => c(wrapper.vm) so that next can be called and our

View file

@ -1,31 +1,21 @@
import yearQuestion from "@/layouts/vehicle-year/year-question/year-question"; import yearQuestion from "@/layouts/vehicle-year/year-question/year-question";
import { shallowMount } from "@vue/test-utils"; import { shallowMount } from "@vue/test-utils";
import { getMountOptions } from "../../../helpers/unit-test-helper";
describe('year-question.vue', () => { describe('year-question.vue', () => {
test('year-question should take a prop for years and questionText, and trigger a selectYear function when an option is clicked.', async () => { test('year-question should take a prop for years and questionText, and trigger a selectYear function when an option is clicked.', async () => {
// Arrange
const mockData = {
store: {
commit: jest.fn(),
year: null
},
router: {
push: jest.fn()
}
}
const mountOptions = getMountOptions(mockData);
// Act // Act
const wrapper = shallowMount(yearQuestion, mountOptions); const wrapper = shallowMount(yearQuestion);
await wrapper.setProps({ await wrapper.setProps({
questionText: 'What year is your vehicle?', questionText: 'What year is your vehicle?',
years: ['2023', '2022', '2021'] years: ['2023', '2022', '2021'],
modelValue: '2020'
}); });
wrapper.vm.$options.watch.selectedYear.call(wrapper.vm);
// Assert // Assert
const radioQuestion = await wrapper.findComponent({name: 'radioQuestion'}); const radioQuestion = await wrapper.findComponent({name: 'radioQuestion'});
expect(radioQuestion.attributes('questiontext')).toBe("What year is your vehicle?"); expect(radioQuestion.attributes('questiontext')).toBe("What year is your vehicle?");
expect(radioQuestion.attributes('answers')).toBe("2023,2022,2021"); expect(radioQuestion.attributes('answers')).toBe("2023,2022,2021");
expect(wrapper.componentVM.modelValue).toBe("2020");
}); });
}); });

View file

@ -21,8 +21,6 @@ export default {
years: Array, years: Array,
modelValue: String modelValue: String
}, },
created() {
},
components: { components: {
radioQuestion, radioQuestion,
}, },

View file

@ -8,7 +8,7 @@
<template> <template>
<!-- IMPORTANT: Refrain from using more than 4 horizontal radio buttons on desktop, 3 on mobile. --> <!-- IMPORTANT: Refrain from using more than 4 horizontal radio buttons on desktop, 3 on mobile. -->
<div class="col radiogroup radio-horizontal d-flex flex-column mb-2"> <div class="col radiogroup radio-horizontal d-flex flex-column mb-2">
<input type="radio" :id="radioID" :name="groupName" :value="radioID" aria-required="true"/> <input type="radio" :id="radioID" :name="groupName" :value="radioID" aria-required="true" @keyup.space="displayComponent"/>
<label role="radio" tabindex="-1" aria-checked="false" :for="radioID" class="d-flex flex-column justify-content-center py-3 px-4" :class="isFirstOrLastButton" @click='displayComponent'> <label role="radio" tabindex="-1" aria-checked="false" :for="radioID" class="d-flex flex-column justify-content-center py-3 px-4" :class="isFirstOrLastButton" @click='displayComponent'>
<span class="m-0" :class="[this.textPosition]">{{radioID}}</span> <span class="m-0" :class="[this.textPosition]">{{radioID}}</span>
<span class="m-0 small" :class="[this.textPosition]">{{radioLabelSubCopy}}</span> <span class="m-0 small" :class="[this.textPosition]">{{radioLabelSubCopy}}</span>

View file

@ -7,7 +7,7 @@
<!-- Example --> <!-- Example -->
<!-- <h3 class="visually-hidden" id="demo-radio-group">Select Vehicle Year</h3> --> <!-- <h3 class="visually-hidden" id="demo-radio-group">Select Vehicle Year</h3> -->
<div class="radiogroup radio-list-button d-flex flex-column w-100 mb-2"> <div class="radiogroup radio-list-button d-flex flex-column w-100 mb-2">
<input type="radio" :id="radioID" :name="groupName" :value="radioID" aria-required="true"> <input type="radio" :id="radioID" :name="groupName" :value="radioID" aria-required="true" @keyup.space="displayComponent">
<label role="radio" tabindex="-1" aria-checked="false" :for="radioID" class="d-flex flex-column justify-content-center py-3 px-4" @click='displayComponent'> <label role="radio" tabindex="-1" aria-checked="false" :for="radioID" class="d-flex flex-column justify-content-center py-3 px-4" @click='displayComponent'>
<span class="m-0" :class="[this.textPosition]">{{radioID}}</span> <span class="m-0" :class="[this.textPosition]">{{radioID}}</span>
<span class="m-0 small" :class="[this.textPosition]">{{radioLabelSubCopy}}</span> <span class="m-0 small" :class="[this.textPosition]">{{radioLabelSubCopy}}</span>