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..c38a445ef --- /dev/null +++ b/src/common-components/dropdown-question/dropdown-question.spec.js @@ -0,0 +1,95 @@ +import { shallowMount } from "@vue/test-utils"; +import textboxQuestion from "./textbox-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("input"); + + // 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("input"); + + 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("input"); + + // 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("input"); + + // Expect + expect(input.attributes().id).toEqual("input ID"); + }); + + it("Should return placeholder text", async () => { + // Act + const wrapper = shallowMount(dropdownQuestion, { + propsData: { + placeholderText: "placeholder text", + }, + }); + + // Assert + const placeholder = wrapper.find("input"); + + expect(placeholder.text()).toEqual("placeholder text"); + }); + +}); 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..7481d43f1 --- /dev/null +++ b/src/common-components/dropdown-question/dropdown-question.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/src/common-components/textbox-question/textbox-question.vue b/src/common-components/textbox-question/textbox-question.vue index 35d8d69f2..9df4c19e7 100644 --- a/src/common-components/textbox-question/textbox-question.vue +++ b/src/common-components/textbox-question/textbox-question.vue @@ -10,7 +10,6 @@ export default { name: "textboxQuestion", props: { - isEnabled: Boolean, isDisabled: Boolean, modelValue: String, labelText: String, diff --git a/src/layouts/component-test/component-test.vue b/src/layouts/component-test/component-test.vue index 12e9f75b8..4a8547a26 100644 --- a/src/layouts/component-test/component-test.vue +++ b/src/layouts/component-test/component-test.vue @@ -2,7 +2,7 @@
-

Textbox Input

+

Text Input

@@ -36,6 +36,39 @@ />
+
+
+

Dropdown Input (select)

+
+
+
+
+ +
+
+
+
+
Disabled
+ +
+
+
+
+
With Error (class="has-error"):
+ +
+

Checkbox

@@ -1077,6 +1110,7 @@ import radio from "@/ux-components/radio/radio"; import textLink from "@/ux-components/text-link/text-link"; import textboxQuestion from "@/common-components/textbox-question/textbox-question"; + import dropdownQuestion from "@/common-components/dropdown-question/dropdown-question"; export default { name: "App", components: { @@ -1090,6 +1124,7 @@ radio, textLink, textboxQuestion, + dropdownQuestion, }, data() { return { diff --git a/src/styles/common-error-styles.scss b/src/styles/common-error-styles.scss index 14b201e05..670591d11 100644 --- a/src/styles/common-error-styles.scss +++ b/src/styles/common-error-styles.scss @@ -32,11 +32,13 @@ border: 1px solid $blue; } } - &.textbox-question { + &.textbox-question, + &.dropdown-question { p { color: $red; } - input { + input, + select { border: 1px solid $red; &:focus { border: 1px solid transparent;