diff --git a/jest.config.js b/jest.config.js index 36c4507fc..b8beb88cc 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,6 +13,8 @@ module.exports = { "!src/helpers/unit-test-helper.js", "!src/layouts/component-test/component-test.vue", "!src/layouts/form-test/form-test.vue", + "!src/layouts/vehicle-damage/windshield-damage-type-question/windshield-damage-type-question.vue", + "!src/layouts/vehicle-damage/windshield-options/windshield-options.vue", "!src/layouts/address-poc/address-poc.vue", ], //! means exclude from coverage. testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"], diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue index 0799446d5..417230464 100644 --- a/src/common-components/button-question/button-question.vue +++ b/src/common-components/button-question/button-question.vue @@ -32,10 +32,14 @@ :colLength="this.answers.length < 3 ? '' : '-4'" :selectedButtonIDs="selectedValues" data-test="button" + :validationRules="validationRules" /> +
+ +
@@ -43,6 +47,7 @@ import listButton from "@/ux-components/list-button/list-button"; import listButtonHorizontal from "@/ux-components/list-button-horizontal/list-button-horizontal"; import listCard from "@/ux-components/list-card/list-card"; +import { ErrorMessage } from 'vee-validate'; import radio from "@/ux-components/radio/radio"; export default { @@ -77,6 +82,10 @@ export default { isOverflowScrollable: Boolean, isWide: Boolean, modelValue: Array, + validationRules: String, + name: String, + value: String, + suppressError: Boolean, }, computed: { getFieldSetClasses() { @@ -119,6 +128,9 @@ export default { } }, methods: { + chooseAnswer(answer) { + this.$emit("update:modelValue", answer); + }, handleCheckedChanged(val) { if(this.isMultiSelect) { // Add or remove item to array of data to emit @@ -134,6 +146,7 @@ export default { listButton, listButtonHorizontal, listCard, + ErrorMessage, radio, }, }; diff --git a/src/common-components/funnel-footer/funnel-footer.spec.js b/src/common-components/funnel-footer/funnel-footer.spec.js index 1c173b6be..6b2bd8335 100644 --- a/src/common-components/funnel-footer/funnel-footer.spec.js +++ b/src/common-components/funnel-footer/funnel-footer.spec.js @@ -5,7 +5,6 @@ describe("funnel-footer.vue", () => { it("Should return footer-link class", async () => { // Act - const r = { test:"testing", clientHeight: 10, @@ -18,43 +17,38 @@ describe("funnel-footer.vue", () => { const wrapper = mount(funnelFooter, { }); + wrapper.vm.initializeComponent(cmsContent); // Assert const link = wrapper.find("a"); - console.log(wrapper.html()); // Expect expect(link.attributes('class')).toContain("footer"); }); - it("Should return link text", async () => { + it("Should emit ForwardClicked on button click", async () => { // Act const wrapper = mount(funnelFooter, { - propsData: { - text: "Terms of use", - }, }); - + wrapper.vm.buttonClick(); // Assert - const link = wrapper.find("a"); - - expect(link.text()).toEqual("Terms of use"); + expect(wrapper.emitted()["ForwardClicked"][0]).toHaveBeenCalled; }); - it("Should return class btn-primary", async () => { + it("Should emit BackClicked on link click", async () => { // Act const wrapper = mount(funnelFooter, { - propsData: { - isPrimary: true, - }, }); - + wrapper.vm.linkClick(); // Assert - const input = wrapper.find("button"); - - // Expect - expect(input.attributes("class")).toContain("btn-primary"); + expect(wrapper.emitted()["BackClicked"][0]).toHaveBeenCalled; }); }); + +//Mock CMS content +const cmsContent = { + backLink: "text", + buttonText: "text", +}; diff --git a/src/common-components/funnel-footer/funnel-footer.vue b/src/common-components/funnel-footer/funnel-footer.vue index e61943761..05409f738 100644 --- a/src/common-components/funnel-footer/funnel-footer.vue +++ b/src/common-components/funnel-footer/funnel-footer.vue @@ -17,7 +17,15 @@
- +