diff --git a/jest.config.js b/jest.config.js index c712c24da..aaf2d9ff8 100644 --- a/jest.config.js +++ b/jest.config.js @@ -26,7 +26,7 @@ module.exports = { testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"], coverageThreshold: { global: { - statements: 77, + statements: 75, // Got the go ahead from Mark to temporarily lower this. Taking out initialize component made the year,make,model and style coverage drop a bit. Once unit tests for license plate lookup, vin lookup and address lookup are in the coverage should go back up to 90 }, }, diff --git a/src/constants/error-messages.js b/src/constants/error-messages.js index 810929d20..415647879 100644 --- a/src/constants/error-messages.js +++ b/src/constants/error-messages.js @@ -27,6 +27,8 @@ const errorMessages = { VEHICLE_REQUIRED: "Please select a vehicle", MOBILE_LOCATION_REQUIRED: "Please enter your service address", DATE_REQUIRED: "Please select a date", + PHONE_REQUIRED: "Please enter your phone number", + PHONE_FORMAT: "Phone number must be 10 digits", }; export { errorMessages }; diff --git a/src/ux-components/checkbox/checkbox.spec.js b/src/digital-components/checkbox-question/checkbox-question.spec.js similarity index 66% rename from src/ux-components/checkbox/checkbox.spec.js rename to src/digital-components/checkbox-question/checkbox-question.spec.js index e231ecc77..3c5d75bf9 100644 --- a/src/ux-components/checkbox/checkbox.spec.js +++ b/src/digital-components/checkbox-question/checkbox-question.spec.js @@ -1,14 +1,25 @@ import { shallowMount } from "@vue/test-utils"; -import checkbox from "./checkbox"; +import checkboxQuestion from "./checkbox-question"; import { nextTick } from "vue"; -describe("checkbox.vue", () => { +// Mock CMS content +const questionText = "Question Text"; +const mockMixin = { + methods: { + getCmsContent: jest.fn().mockImplementation(() => { + return questionText; + }), + }, +}; + +describe("checkbox-question.vue", () => { it("Should return checkbox name", async () => { // Act - const wrapper = shallowMount(checkbox, { + const wrapper = shallowMount(checkboxQuestion, { propsData: { checkboxName: "Checkbox", }, + mixins: [mockMixin], }); // Assert @@ -20,10 +31,11 @@ describe("checkbox.vue", () => { it("Should return checkbox id", async () => { // Act - const wrapper = shallowMount(checkbox, { + const wrapper = shallowMount(checkboxQuestion, { propsData: { buttonID: "Checkbox ID", }, + mixins: [mockMixin], }); // Assert @@ -35,10 +47,11 @@ describe("checkbox.vue", () => { it("Should return tabindex value", async () => { // Act - const wrapper = shallowMount(checkbox, { + const wrapper = shallowMount(checkboxQuestion, { propsData: { tabIndex: "1", }, + mixins: [mockMixin], }); // Assert @@ -50,24 +63,11 @@ describe("checkbox.vue", () => { 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, { + const wrapper = shallowMount(checkboxQuestion, { propsData: { screenReaderOnlyText: "screenreader text", }, + mixins: [mockMixin], }); // Assert diff --git a/src/ux-components/checkbox/checkbox.vue b/src/digital-components/checkbox-question/checkbox-question.vue similarity index 72% rename from src/ux-components/checkbox/checkbox.vue rename to src/digital-components/checkbox-question/checkbox-question.vue index cbc1120c5..e63c24523 100644 --- a/src/ux-components/checkbox/checkbox.vue +++ b/src/digital-components/checkbox-question/checkbox-question.vue @@ -2,6 +2,7 @@
@@ -18,15 +19,32 @@ diff --git a/src/digital-components/phonenumber-question/phonenumber-question.spec.js b/src/digital-components/phonenumber-question/phonenumber-question.spec.js new file mode 100644 index 000000000..3d0843e10 --- /dev/null +++ b/src/digital-components/phonenumber-question/phonenumber-question.spec.js @@ -0,0 +1 @@ +test.todo("some test to be written in the future"); diff --git a/src/digital-components/phonenumber-question/phonenumber-question.vue b/src/digital-components/phonenumber-question/phonenumber-question.vue new file mode 100644 index 000000000..8a5ba052c --- /dev/null +++ b/src/digital-components/phonenumber-question/phonenumber-question.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/src/digital-components/textarea-question/textarea-question.spec.js b/src/digital-components/textarea-question/textarea-question.spec.js new file mode 100644 index 000000000..3d0843e10 --- /dev/null +++ b/src/digital-components/textarea-question/textarea-question.spec.js @@ -0,0 +1 @@ +test.todo("some test to be written in the future"); diff --git a/src/digital-components/textarea-question/textarea-question.vue b/src/digital-components/textarea-question/textarea-question.vue new file mode 100644 index 000000000..e4e48092d --- /dev/null +++ b/src/digital-components/textarea-question/textarea-question.vue @@ -0,0 +1,126 @@ + + + + + diff --git a/src/digital-components/textbox-question/textbox-question.vue b/src/digital-components/textbox-question/textbox-question.vue index a4de11254..19f35715c 100644 --- a/src/digital-components/textbox-question/textbox-question.vue +++ b/src/digital-components/textbox-question/textbox-question.vue @@ -44,7 +44,8 @@ @change="handleChange" @blur="handleChange" :maxlength="maxLength ? maxLength : '999'" - @focus="$emit('focus', $event.target.value)" /> + @focus="$emit('focus', $event.target.value)" + @keydown="keyDownHandler" />