diff --git a/src/layouts/service-location/appointment-type-question/appointment-type-question.spec.js b/src/layouts/service-location/appointment-type-question/appointment-type-question.spec.js index 65fba87f2..63242df22 100644 --- a/src/layouts/service-location/appointment-type-question/appointment-type-question.spec.js +++ b/src/layouts/service-location/appointment-type-question/appointment-type-question.spec.js @@ -1,6 +1,13 @@ import { shallowMount } from "@vue/test-utils"; import { getMountOptions } from "@/helpers/unit-test-helper.js"; import appointmentTypeQuestion from "./appointment-type-question"; +import store from "@/store"; + +store.getters = { + damage: { + isRepair: false, + }, +}; const mockCmsContent = { QuestionText: "Choose a service option:", @@ -42,6 +49,15 @@ const mockMixin = { }, }; +afterEach(() => { + // reset store after each test + store.getters = { + damage: { + isRepair: false, + }, + }; +}); + describe("appointment-type-question.vue", () => { it("Should display all options if both in-shop and mobile are available", async () => { // Arrange/Act @@ -141,6 +157,45 @@ describe("appointment-type-question.vue", () => { }, ]); }); + it("Should not display Drop off answer when it is repair order", async () => { + // Arrange/Act + + store.getters = { + damage: { + isRepair: true, + }, + }; + + const { wrapper } = setupMocks({ + mixins: [mockMixin], + props: { + cmsWidgetName: cmsWidgetName, + isServiceableInshop: true, + isServiceableMobile: true, + }, + mountOptions: { + attachTo: document.body, + }, + }); + + // Assert + expect(wrapper.vm.answersToDisplay).toEqual([ + { + AnswerImageUrl: "", + Name: "Mobile", + SubText: "", + SubWidgetName: "", + Text: "Mobile", + }, + { + AnswerImageUrl: "", + Name: "Inshop", + SubText: "", + SubWidgetName: "", + Text: "In-shop", + }, + ]); + }); it("Should display no answers if neither in-shop nor mobile service are available", async () => { // Arrange/Act @@ -169,6 +224,8 @@ function setupMocks({ mountOptions, mixins, props, isShallowMount = true }) { if (props) resultingMountOptions.propsData = props; + resultingMountOptions.global.mocks["$store"] = store; + const wrapper = isShallowMount ? shallowMount(appointmentTypeQuestion, resultingMountOptions) : mount(appointmentTypeQuestion, resultingMountOptions); diff --git a/src/layouts/service-location/appointment-type-question/appointment-type-question.vue b/src/layouts/service-location/appointment-type-question/appointment-type-question.vue index cce1a4d5b..732382b1a 100644 --- a/src/layouts/service-location/appointment-type-question/appointment-type-question.vue +++ b/src/layouts/service-location/appointment-type-question/appointment-type-question.vue @@ -18,6 +18,7 @@