diff --git a/src/common-components/dropdown-question/dropdown-question.spec.js b/src/common-components/dropdown-question/dropdown-question.spec.js new file mode 100644 index 000000000..0d1095c94 --- /dev/null +++ b/src/common-components/dropdown-question/dropdown-question.spec.js @@ -0,0 +1,81 @@ +import { shallowMount } from "@vue/test-utils"; +import dropdownQuestion from "./dropdown-question"; +import { nextTick } from "vue"; + +describe("dropdownQuestion.vue", () => { + + it("Should return aria-disabled state", async () => { + // Act + const wrapper = shallowMount(dropdownQuestion, { + propsData: { + isDisabled: true, + }, + }); + + // Assert + const input = wrapper.find("select"); + + // Expect + expect(input.attributes()["aria-disabled"]).toEqual("true"); + }); + + it("Should render a text input", async () => { + // Act + const wrapper = shallowMount(dropdownQuestion, { + propsData: { + name: "test", + label: "unit test label", + }, + }); + + // Assert + const input = wrapper.find("select"); + + expect(input.exists()).toBe(true); + }); + + it("Should return input id", async () => { + // Act + const wrapper = shallowMount(dropdownQuestion, { + propsData: { + inputId: "input ID", + }, + }); + + // Assert + const input = wrapper.find("select"); + + // Expect + expect(input.attributes().id).toEqual("input ID"); + }); + + it("Should return label text", async () => { + // Act + const wrapper = shallowMount(dropdownQuestion, { + propsData: { + labelText: "label text", + }, + }); + + // Assert + const label = wrapper.find("label"); + + expect(label.text()).toEqual("label text"); + }); + + it("Should return input id", async () => { + // Act + const wrapper = shallowMount(dropdownQuestion, { + propsData: { + inputId: "input ID", + }, + }); + + // Assert + const input = wrapper.find("select"); + + // Expect + expect(input.attributes().id).toEqual("input ID"); + }); + +}); diff --git a/src/common-components/dropdown-question/dropdown-question.vue b/src/common-components/dropdown-question/dropdown-question.vue new file mode 100644 index 000000000..7793a01ad --- /dev/null +++ b/src/common-components/dropdown-question/dropdown-question.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/src/common-components/textbox-question/textbox-question.spec.js b/src/common-components/textbox-question/textbox-question.spec.js new file mode 100644 index 000000000..721fba9d5 --- /dev/null +++ b/src/common-components/textbox-question/textbox-question.spec.js @@ -0,0 +1,81 @@ +import { shallowMount } from "@vue/test-utils"; +import textboxQuestion from "./textbox-question"; +import { nextTick } from "vue"; + +describe("textboxQuestion.vue", () => { + + it("Should return aria-disabled state", async () => { + // Act + const wrapper = shallowMount(textboxQuestion, { + propsData: { + isDisabled: true, + }, + }); + + // Assert + const input = wrapper.find("input"); + + // Expect + expect(input.attributes()["aria-disabled"]).toEqual("true"); + }); + + it("Should render a text input", async () => { + // Act + const wrapper = shallowMount(textboxQuestion, { + propsData: { + name: "test", + label: "unit test label", + }, + }); + + // Assert + const input = wrapper.find("input"); + + expect(input.exists()).toBe(true); + }); + + it("Should return input id", async () => { + // Act + const wrapper = shallowMount(textboxQuestion, { + propsData: { + inputId: "input ID", + }, + }); + + // Assert + const input = wrapper.find("input"); + + // Expect + expect(input.attributes().id).toEqual("input ID"); + }); + + it("Should return label text", async () => { + // Act + const wrapper = shallowMount(textboxQuestion, { + propsData: { + labelText: "label text", + }, + }); + + // Assert + const label = wrapper.find("label"); + + expect(label.text()).toEqual("label text"); + }); + + it("Should return input id", async () => { + // Act + const wrapper = shallowMount(textboxQuestion, { + propsData: { + inputId: "input ID", + }, + }); + + // Assert + const input = wrapper.find("input"); + + // Expect + expect(input.attributes().id).toEqual("input ID"); + }); + +}); diff --git a/src/common-components/textbox-question/textbox-question.vue b/src/common-components/textbox-question/textbox-question.vue new file mode 100644 index 000000000..9df4c19e7 --- /dev/null +++ b/src/common-components/textbox-question/textbox-question.vue @@ -0,0 +1,52 @@ + + + + + diff --git a/src/layouts/component-test/component-test.vue b/src/layouts/component-test/component-test.vue index e18664bec..d75266010 100644 --- a/src/layouts/component-test/component-test.vue +++ b/src/layouts/component-test/component-test.vue @@ -1,5 +1,74 @@