diff --git a/src/common-components/button-question-modal/button-question-modal.spec.js b/src/common-components/button-question-modal/button-question-modal.spec.js new file mode 100644 index 00000000..dc7ac5b4 --- /dev/null +++ b/src/common-components/button-question-modal/button-question-modal.spec.js @@ -0,0 +1,52 @@ +import { shallowMount } from "@vue/test-utils"; +import ButtonQuestionModal from "./button-question-modal"; + +describe("button-question-modal.vue", () => { + it("Should display header text when QuestionText is defined in the CMS", async () => { + // Act + const wrapper = shallowMount(ButtonQuestionModal, { + mixins: [mockMixin], + props: { + cmsWidgetName: "test", + }, + attachTo: document.body, + }); + expect(wrapper.html()).toEqual(expect.stringContaining(mockCmsContent["QuestionText"])); + }); + + it("Should display subheader text when ButtonText is defined in the CMS", async () => { + // Act + const wrapper = shallowMount(ButtonQuestionModal, { + mixins: [mockMixin], + props: { + cmsWidgetName: "test", + }, + attachTo: document.body, + }); + expect(wrapper.html()).toEqual(expect.stringContaining(mockCmsContent["ButtonText"])); + }); + +}); + +const mockMixin = { + methods: { + getCmsContent: jest.fn((widgetName, cmsFieldName) => { + return mockCmsContent[cmsFieldName]; + }), + }, +}; + +const mockCmsContent = { + QuestionText: "What caused damage.", + ButtonText: "Select an option.", + Answers: [ + { + Name: "Rock from road", + Text: "Rock from road" + }, + { + Name: "Vandalism", + Text: "Vandalism" + }, + ], +}; diff --git a/src/common-components/button-question-modal/button-question-modal.vue b/src/common-components/button-question-modal/button-question-modal.vue index f0d2ce6d..223186ae 100644 --- a/src/common-components/button-question-modal/button-question-modal.vue +++ b/src/common-components/button-question-modal/button-question-modal.vue @@ -28,6 +28,7 @@ :answers="ModalSelectOptionAnswers" groupName="ChooseVehicleYear" v-model="selectedValue" + :validationRules="validationRules" isRequired />
-