diff --git a/src/common-components/text-input/text-input.spec.js b/src/common-components/text-input/text-input.spec.js new file mode 100644 index 000000000..fcb08d57a --- /dev/null +++ b/src/common-components/text-input/text-input.spec.js @@ -0,0 +1,38 @@ +import { shallowMount } from "@vue/test-utils"; +import textInput from "./text-input"; + +describe("text-input.vue", () => { + + it("Should render a text input", async () => { + // Act + const wrapper = shallowMount(textInput, { + propsData: { + name: "test", + label: "unit test label", + }, + }); + + // Assert + const input = wrapper.find("input"); + + expect(input.exists()).toBe(true); + }); + + it("Should return aria-required state", async () => { + // Act + const wrapper = shallowMount(textInput, { + propsData: { + name: "test", + label: "unit test label", + isRequired: true + }, + }); + + // Assert + const input = wrapper.find("input"); + + expect(input.attributes()["aria-required"]).toEqual("true"); + + }); + +}); \ No newline at end of file diff --git a/src/common-components/text-input/text-input.vue b/src/common-components/text-input/text-input.vue new file mode 100644 index 000000000..50096a52f --- /dev/null +++ b/src/common-components/text-input/text-input.vue @@ -0,0 +1,70 @@ + + + + diff --git a/src/layouts/form-test/form-test.vue b/src/layouts/form-test/form-test.vue index 96bc9bd33..4d0ef09bd 100644 --- a/src/layouts/form-test/form-test.vue +++ b/src/layouts/form-test/form-test.vue @@ -1,8 +1,8 @@