commit
369df5b8b6
4 changed files with 58 additions and 10 deletions
|
|
@ -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"
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
:answers="ModalSelectOptionAnswers"
|
:answers="ModalSelectOptionAnswers"
|
||||||
groupName="ChooseVehicleYear"
|
groupName="ChooseVehicleYear"
|
||||||
v-model="selectedValue"
|
v-model="selectedValue"
|
||||||
|
:validationRules="validationRules"
|
||||||
isRequired />
|
isRequired />
|
||||||
<div class="modal-footer px-5 py-4">
|
<div class="modal-footer px-5 py-4">
|
||||||
<buttonMain
|
<buttonMain
|
||||||
|
|
@ -47,20 +48,12 @@
|
||||||
<script>
|
<script>
|
||||||
import buttonMain from "@/ux-components/button-main/button-main";
|
import buttonMain from "@/ux-components/button-main/button-main";
|
||||||
import buttonQuestion from "@/common-components/button-question/button-question";
|
import buttonQuestion from "@/common-components/button-question/button-question";
|
||||||
import { defineRule } from "vee-validate";
|
|
||||||
import { required } from "@/helpers/validation-rules";
|
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "buttonQuestionModal",
|
name: "buttonQuestionModal",
|
||||||
props: {
|
props: {
|
||||||
cmsWidgetName: String,
|
cmsWidgetName: String,
|
||||||
},
|
},
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
answers: [],
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
ModalQuestionText() {
|
ModalQuestionText() {
|
||||||
return this.getCmsContent(this.cmsWidgetName, "QuestionText");
|
return this.getCmsContent(this.cmsWidgetName, "QuestionText");
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
validationRules="damage-cause-required" />
|
validationRules="damage-cause-required" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<buttonQuestionModal cmsWidgetName="DamageCauseQuestion" />
|
<buttonQuestionModal cmsWidgetName="DamageCauseQuestion" validationRules="damage-cause-required" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,9 @@ export default {
|
||||||
this.$emit("click-event");
|
this.$emit("click-event");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
resetButtonStyle() {
|
||||||
|
this.isLoaderDisplayed = false;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
loader,
|
loader,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue