Merge pull request #81 from Safelite/feature/CSR-74

Feature/csr 74
This commit is contained in:
max-dempsey 2021-12-06 15:54:05 -05:00 committed by GitHub
commit 918addb3cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 20 deletions

View file

@ -8,9 +8,7 @@ describe("radioQuestion.vue", () => {
propsData: { propsData: {
questionText: "Question Text", questionText: "Question Text",
answers: ["2023", "2022", "2021"], answers: ["2023", "2022", "2021"],
chooseAnswer: function (test) { modelValue: '2020'
console.log(test);
},
}, },
}); });
@ -20,6 +18,6 @@ describe("radioQuestion.vue", () => {
); );
const radioButtons = wrapper.findAllComponents('[data-test="radio"]'); const radioButtons = wrapper.findAllComponents('[data-test="radio"]');
expect(radioButtons.length).toBe(3); expect(radioButtons.length).toBe(3);
expect(typeof wrapper.props().chooseAnswer).toBe("function"); expect(wrapper.props().modelValue).toBe("2020");
}); });
}); });

View file

@ -17,6 +17,7 @@
data-test="radio" data-test="radio"
groupName="radio-list" groupName="radio-list"
textPosition="text-start" textPosition="text-start"
:value="modelValue"
/> />
</div> </div>
</div> </div>
@ -30,7 +31,13 @@ export default {
props: { props: {
questionText: String, questionText: String,
answers: Array, answers: Array,
chooseAnswer: Function, modelValue: String
},
emits: ['update:modelValue'],
methods: {
chooseAnswer(answer) {
this.$emit('update:modelValue', answer);
}
}, },
components: { components: {
radio, radio,

View file

@ -3,7 +3,7 @@
<div class="select-car-form rounded text-center"> <div class="select-car-form rounded text-center">
<vehicleBanner :vehicleImageSrc="vehicleBannerWidget.GenericVehicleImage" /> <vehicleBanner :vehicleImageSrc="vehicleBannerWidget.GenericVehicleImage" />
<pageHeader :text="pageHeaderWidgets.HeaderText" class="Header" /> <pageHeader :text="pageHeaderWidgets.HeaderText" class="Header" />
<yearQuestion :questionText="radioQuestionWidgets.QuestionText" :years="vehicleYears" /> <yearQuestion :questionText="radioQuestionWidgets.QuestionText" :years="vehicleYears" v-model="selectedYear" />
</div> </div>
</div> </div>
</template> </template>
@ -25,7 +25,8 @@ export default {
pageHeaderWidgets: {}, pageHeaderWidgets: {},
radioQuestionWidgets: {}, radioQuestionWidgets: {},
vehicleYears: [], vehicleYears: [],
vehicleBannerWidget: {} vehicleBannerWidget: {},
selectedYear: null
}; };
}, },
computed: {}, computed: {},
@ -59,6 +60,13 @@ export default {
}); });
}, },
watch: {
selectedYear(year) {
this.$store.commit(this.storeMutations.UPDATE_YEAR, year);
this.$router.push('?fmgPage=vehicle-make');
}
},
components: { components: {
yearQuestion, yearQuestion,
pageHeader, pageHeader,

View file

@ -14,9 +14,6 @@ describe('year-question.vue', () => {
push: jest.fn() push: jest.fn()
} }
} }
mockData.store.commit.mockImplementation((method, year) => {
mockData.store.year = year;
});
const mountOptions = getMountOptions(mockData); const mountOptions = getMountOptions(mockData);
// Act // Act
@ -25,12 +22,10 @@ describe('year-question.vue', () => {
questionText: 'What year is your vehicle?', questionText: 'What year is your vehicle?',
years: ['2023', '2022', '2021'] years: ['2023', '2022', '2021']
}); });
wrapper.vm.selectYear(2020);
// 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(mockData.store.year).toBe(2020);
}); });
}); });

View file

@ -2,7 +2,7 @@
<radioQuestion class="radioQuestion" <radioQuestion class="radioQuestion"
:questionText="questionText" :questionText="questionText"
:answers="years" :answers="years"
:chooseAnswer="selectYear" v-model="selectedYear"
/> />
</template> </template>
@ -11,20 +11,25 @@ import radioQuestion from "@/common-components/radio-question/radio-question";
export default { export default {
name: "year-question", name: "year-question",
data(){
return {
selectedYear: null
}
},
props: { props: {
questionText: String, questionText: String,
years: Array years: Array,
modelValue: String
}, },
created() { created() {
}, },
components: { components: {
radioQuestion, radioQuestion,
}, },
methods: { watch: {
selectYear(year){ selectedYear(val) {
this.$store.commit(this.storeMutations.UPDATE_YEAR, year); this.$emit('update:modelValue', val)
this.$router.push('?fmgPage=vehicle-make'); }
} }
},
}; };
</script> </script>