From 352c3c69b9a44486dc3ab5fa7375e59bbd932f5c Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 2 Mar 2022 13:12:14 -0500 Subject: [PATCH] Radio button fix and radio button unit tests added --- src/ux-components/radio/radio.spec.js | 38 +++++++++++++++++++++++++++ src/ux-components/radio/radio.vue | 32 +++++++++++----------- 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/src/ux-components/radio/radio.spec.js b/src/ux-components/radio/radio.spec.js index a7c3318ed..113d534c6 100644 --- a/src/ux-components/radio/radio.spec.js +++ b/src/ux-components/radio/radio.spec.js @@ -60,4 +60,42 @@ describe("radio.vue", () => { expect(paragraph.text()).toEqual("screenreader text"); }); + + it("Should emit button value on click", async () => { + // Act + const wrapper = shallowMount(radio, { + propsData: { + buttonLabel: "Windshield", + value: "List Card Checkbox", + buttonID: "List Card Checkbox", + groupID: "radio-demo-1", + groupName: "radio 1", + isRequired: true, + isWide: false, + modelValue: ["List Card Checkbox"], + }, + }); + wrapper.vm.handleCheckChange(); + // Assert + expect(wrapper.emitted()["isCheckedChanged"][0]).toEqual([{"buttonID": "List Card Checkbox", value: "List Card Checkbox", checkValue: Boolean}]); + }); + + it("Should set checkValue data if selectedButtonIDs has value(s)", async () => { + // Act + const wrapper = shallowMount(radio, { + propsData: { + buttonLabel: "Windshield", + buttonID: "List Card Checkbox", + groupID: "radio-demo-1", + groupName: "radio 1", + buttonImage: "windshield-damage.svg", + isRequired: true, + modelValue: ["List Card Checkbox"], + value: "Car-Front", + selectedValues: ["Car-Front"] + }, + }); + // Assert + expect(wrapper.componentVM.checkValue).toEqual(true); + }); }); diff --git a/src/ux-components/radio/radio.vue b/src/ux-components/radio/radio.vue index 99629a39b..17fb7a880 100644 --- a/src/ux-components/radio/radio.vue +++ b/src/ux-components/radio/radio.vue @@ -10,7 +10,8 @@ :aria-required="isRequired" :value="value" :v-model="checkValue" - @change="handleCheckChanged()" + @change="handleCheckChange()" + :checked="checkValue" />