From 79455adab35a0463558fef21ea8202f71c697af3 Mon Sep 17 00:00:00 2001 From: bmauger Date: Wed, 5 Jan 2022 17:00:59 -0500 Subject: [PATCH] CSR-241 WIP unit test. --- src/ux-components/list-card/list-card.spec.js | 66 ++++++++++++++++++- src/ux-components/list-card/list-card.vue | 13 ++-- 2 files changed, 72 insertions(+), 7 deletions(-) diff --git a/src/ux-components/list-card/list-card.spec.js b/src/ux-components/list-card/list-card.spec.js index 3d0843e10..736fed6b9 100644 --- a/src/ux-components/list-card/list-card.spec.js +++ b/src/ux-components/list-card/list-card.spec.js @@ -1 +1,65 @@ -test.todo("some test to be written in the future"); +import { shallowMount } from "@vue/test-utils"; +import listCard from "./list-card"; + +describe("list-card.vue", () => { + + it("Should return input type checkbox if isMultiSelect is true", async () => { + // Act + const wrapper = shallowMount(listCard, { + propsData: { + isMultiSelect: true, + buttonLabel: "Windshield", + buttonID: "List Card Checkbox", + groupID: "checkbox-demo-1", + groupName: "Checkbox 1", + buttonImage: "windshield-damage.svg", + }, + }); + + // Assert + const input = wrapper.find("input"); + + expect(input.attributes().type).toEqual("checkbox"); + }); + + it("Should return input type radio if isRadio is true", async () => { + // Act + const wrapper = shallowMount(listCard, { + propsData: { + isRadio: true, + buttonLabel: "Windshield", + buttonID: "List Card Checkbox", + groupID: "radio-demo-1", + groupName: "radio 1", + buttonImage: "windshield-damage.svg", + }, + }); + + // Assert + const input = wrapper.find("input"); + + expect(input.attributes().type).toEqual("radio"); + }); + + it("Should return input type checkbox and class horizontal if isMultiSelectHorizontal is true", async () => { + // Act + const wrapper = shallowMount(listCard, { + propsData: { + isMultiSelectHorizontal: true, + buttonLabel: "Windshield", + buttonID: "List Card Checkbox", + groupID: "radio-demo-1", + groupName: "radio 1", + buttonImage: "windshield-damage.svg", + class: "horizontal" + }, + }); + + // Assert + const input = wrapper.find("input"); + + expect(input.attributes().type).toEqual("checkbox"); + + }); + +}); diff --git a/src/ux-components/list-card/list-card.vue b/src/ux-components/list-card/list-card.vue index 177d43e90..3d2c807bb 100644 --- a/src/ux-components/list-card/list-card.vue +++ b/src/ux-components/list-card/list-card.vue @@ -5,7 +5,7 @@
@@ -13,7 +13,7 @@
@@ -22,7 +22,7 @@

{{buttonLabel}}

-

{{buttonLabelSubCopy}}

+

{{buttonLabelSubCopy}}

@@ -32,7 +32,7 @@

{{buttonLabel}}

-

{{buttonLabelSubCopy}}

+

{{buttonLabelSubCopy}}

@@ -48,11 +48,12 @@ export default { isMultiSelectHorizontal: Boolean,//Defines use as horizontal checkbox isRadioHorizontal: Boolean,//Defines use as horizontal radio button //end must choose - buttonImage: String,//Optional: File name of image + buttonImage: String,//Required: File name of image buttonLabel: String,//Required: Label text + isRequired: Boolean, //Required: is input required or optional? altText: String,//Leave empty. Screen readers read the buttonLabel text. If alt has content, it will repeat unnecessarily. buttonID: String,//Required: Unique - groupName: String,//Rquired: Unique + groupName: String,//Required: Unique buttonLabelSubCopy: String,//Optional: sub text } };