From 357c16539f1d971f1db6f54137fbb646039efd60 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Fri, 7 Jul 2023 08:23:44 -0400 Subject: [PATCH] phone-number-question unit tests --- .../phone-number-question.spec.js | 62 +++++++++ .../phone-number-question.vue | 95 ++++++++++++++ .../phonenumber-question.spec.js | 1 - .../phonenumber-question.vue | 119 ------------------ .../customer-details/customer-details.spec.js | 2 +- .../customer-details/customer-details.vue | 2 +- src/styles/common-error-styles.scss | 2 +- 7 files changed, 160 insertions(+), 123 deletions(-) create mode 100644 src/digital-components/phone-number-question/phone-number-question.spec.js create mode 100644 src/digital-components/phone-number-question/phone-number-question.vue delete mode 100644 src/digital-components/phonenumber-question/phonenumber-question.spec.js delete mode 100644 src/digital-components/phonenumber-question/phonenumber-question.vue diff --git a/src/digital-components/phone-number-question/phone-number-question.spec.js b/src/digital-components/phone-number-question/phone-number-question.spec.js new file mode 100644 index 000000000..a3b6e9424 --- /dev/null +++ b/src/digital-components/phone-number-question/phone-number-question.spec.js @@ -0,0 +1,62 @@ +// Components +import phoneNumberQuestion from "./phone-number-question"; + +// Supporting Files +import { shallowMount } from "@vue/test-utils"; + +describe("phone-number-question.vue", () => { + it("Should render phoneNumberQuestion sub-component (textbox-question)", async () => { + // Arrange + const wrapper = shallowMount(phoneNumberQuestion, {}); + + wrapper.getCmsContent = jest.fn(); + + // Act + const phoneNumber = wrapper.findComponent({ ref: "phoneNumber" }); + + // Assert + expect(phoneNumber.exists()).toBe(true); + }); + + it("Should emit new value when modelValue is changed", async () => { + // Act + const wrapper = shallowMount(phoneNumberQuestion, { + propsData: { + modelValue: "val", + }, + }); + + const phoneNumber = wrapper.findComponent({ ref: "phoneNumber" }); + await phoneNumber.setValue("val2"); + + // Assert + expect(wrapper.emitted("update:modelValue")).toEqual([["val2"]]); + }); + + it("Should emit new value when modelValue is changed", async () => { + // Act + const wrapper = shallowMount(phoneNumberQuestion, { + propsData: { + modelValue: "val", + }, + }); + + const phoneNumber = wrapper.findComponent({ ref: "phoneNumber" }); + await phoneNumber.setValue("val2"); + + // Assert + expect(wrapper.emitted("update:modelValue")).toEqual([["val2"]]); + }); + + it("Should combine external and internal validation rules to pass to textbox-question", async() => { + // Act + const wrapper = shallowMount(phoneNumberQuestion, { + propsData: { + validationRules: "outsideValidation", + }, + }); + + // Assert + expect(wrapper.vm.validationRulesForTextBoxQuestion).toEqual("outsideValidation|phone-number-format"); + }); +}); diff --git a/src/digital-components/phone-number-question/phone-number-question.vue b/src/digital-components/phone-number-question/phone-number-question.vue new file mode 100644 index 000000000..f3fdc6cd6 --- /dev/null +++ b/src/digital-components/phone-number-question/phone-number-question.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/src/digital-components/phonenumber-question/phonenumber-question.spec.js b/src/digital-components/phonenumber-question/phonenumber-question.spec.js deleted file mode 100644 index 3d0843e10..000000000 --- a/src/digital-components/phonenumber-question/phonenumber-question.spec.js +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 7f2525bcb..000000000 --- a/src/digital-components/phonenumber-question/phonenumber-question.vue +++ /dev/null @@ -1,119 +0,0 @@ - - - - - diff --git a/src/layouts/customer-details/customer-details.spec.js b/src/layouts/customer-details/customer-details.spec.js index 2014f47d3..af43c1930 100644 --- a/src/layouts/customer-details/customer-details.spec.js +++ b/src/layouts/customer-details/customer-details.spec.js @@ -55,4 +55,4 @@ function setupMocks() { ); return { wrapper }; -} \ No newline at end of file +} diff --git a/src/layouts/customer-details/customer-details.vue b/src/layouts/customer-details/customer-details.vue index f3b039ee8..9a0d7e554 100644 --- a/src/layouts/customer-details/customer-details.vue +++ b/src/layouts/customer-details/customer-details.vue @@ -55,7 +55,7 @@ import funnelFooter from "@/fmg-components/funnel-footer/funnel-footer"; import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header"; import textareaQuestion from "@/digital-components/textarea-question/textarea-question"; import textboxQuestion from "@/digital-components/textbox-question/textbox-question"; -import phoneNumberQuestion from "@/digital-components/phonenumber-question/phonenumber-question"; +import phoneNumberQuestion from "@/digital-components/phone-number-question/phone-number-question"; import textBlock from "@/digital-components/text-block/text-block"; import checkboxQuestion from "@/digital-components/checkbox-question/checkbox-question"; //Supporting files diff --git a/src/styles/common-error-styles.scss b/src/styles/common-error-styles.scss index ed2e5acbd..8a8c0bd14 100644 --- a/src/styles/common-error-styles.scss +++ b/src/styles/common-error-styles.scss @@ -103,7 +103,7 @@ html { } &.textbox-question, &.dropdown-question, - &.phonenumber-question { + &.phone-number-question { p { color: $red; }