diff --git a/src/ux-components/checkbox/checkbox.spec.js b/src/ux-components/checkbox/checkbox.spec.js new file mode 100644 index 00000000..e231ecc7 --- /dev/null +++ b/src/ux-components/checkbox/checkbox.spec.js @@ -0,0 +1,78 @@ +import { shallowMount } from "@vue/test-utils"; +import checkbox from "./checkbox"; +import { nextTick } from "vue"; + +describe("checkbox.vue", () => { + it("Should return checkbox name", async () => { + // Act + const wrapper = shallowMount(checkbox, { + propsData: { + checkboxName: "Checkbox", + }, + }); + + // Assert + const input = wrapper.find("input"); + + // Expect + expect(input.attributes().name).toEqual("Checkbox"); + }); + + it("Should return checkbox id", async () => { + // Act + const wrapper = shallowMount(checkbox, { + propsData: { + buttonID: "Checkbox ID", + }, + }); + + // Assert + const input = wrapper.find("input"); + + // Expect + expect(input.attributes().id).toEqual("Checkbox ID"); + }); + + it("Should return tabindex value", async () => { + // Act + const wrapper = shallowMount(checkbox, { + propsData: { + tabIndex: "1", + }, + }); + + // Assert + const input = wrapper.find("input"); + + // Expect + expect(input.attributes().tabindex).toEqual("1"); + }); + + it("Should return label text", async () => { + // Act + const wrapper = shallowMount(checkbox, { + propsData: { + checkboxLabel: "label text", + }, + }); + + // Assert + const paragraph = wrapper.find("p"); + + expect(paragraph.text()).toEqual("label text"); + }); + + it("Should return label text", async () => { + // Act + const wrapper = shallowMount(checkbox, { + propsData: { + screenReaderOnlyText: "screenreader text", + }, + }); + + // Assert + const paragraph = wrapper.find("span"); + + expect(paragraph.text()).toEqual("screenreader text"); + }); +}); diff --git a/src/ux-components/checkbox/checkbox.vue b/src/ux-components/checkbox/checkbox.vue new file mode 100644 index 00000000..cbc1120c --- /dev/null +++ b/src/ux-components/checkbox/checkbox.vue @@ -0,0 +1,65 @@ + + + + +