diff --git a/src/digital-components/date-picker/date-picker-2.vue b/src/experiment-components/date-picker-2.vue similarity index 99% rename from src/digital-components/date-picker/date-picker-2.vue rename to src/experiment-components/date-picker-2.vue index 8becf6266..414f794e0 100644 --- a/src/digital-components/date-picker/date-picker-2.vue +++ b/src/experiment-components/date-picker-2.vue @@ -99,8 +99,8 @@ // Supporting files import loader from "@/ux-components/loader/loader"; import store from "@/store"; -import { TIMINGFUNC_MAP, BUFFER_OFFSET, MONTHS_OF_YEAR } from "./mixins/constants"; -import { selectableDaysOptions, requiredParameter, forceTwoDigitString } from "./mixins/helpers"; +import { TIMINGFUNC_MAP, BUFFER_OFFSET, MONTHS_OF_YEAR } from "@/digital-components/date-picker/mixins/constants"; +import { selectableDaysOptions, requiredParameter, forceTwoDigitString } from "@/digital-components/date-picker/mixins/helpers"; import { convertDateToDateString, convertDateStringToDate, diff --git a/src/layouts/insurance-company/insurance-company-spec.js b/src/layouts/insurance-company/insurance-company-spec.js deleted file mode 100644 index bd932b7d2..000000000 --- a/src/layouts/insurance-company/insurance-company-spec.js +++ /dev/null @@ -1,3 +0,0 @@ -describe("insurance-company.vue", () => { - it.todo("Some test for the future"); -}); diff --git a/src/layouts/insurance-company/insurance-company.spec.js b/src/layouts/insurance-company/insurance-company.spec.js new file mode 100644 index 000000000..b1297d13b --- /dev/null +++ b/src/layouts/insurance-company/insurance-company.spec.js @@ -0,0 +1,105 @@ +import { shallowMount } from '@vue/test-utils'; +import InsuranceCompany from '@/layouts/insurance-company/insurance-company.vue'; +import { applicationConfig } from '@/constants/application-config.js'; +import store from "@/store"; +import baseMixin from "@/mixins/base-mixin.js"; + + +jest.mock('@/store', () => ({ + getters: { + order: { + payment: { + parentAccountNumber: '12345', + }, + }, + }, + })); + +var mockRouter = { + navigateWithoutSaving: jest.fn(), + }; + + jest.mock('@/mixins/base-mixin.js', () => ({ + methods: { + navigateWithoutSaving: jest.fn(), + }, + data() { + return { + navigationScenarios: { + CLICKED_BACK: 'clicked_back', + }, + }; + }, + })); + +describe("insurance-company.vue", () => { + + beforeEach(() => { + // Reset the store's parentAccountNumber before each test + store.getters.order.payment.parentAccountNumber = '12345'; + }); + + test('should return true when parentAccountNumber matches CASH_PARENT_ACCOUNT_NUMBER', () => { + applicationConfig.CASH_PARENT_ACCOUNT_NUMBER = "12345"; + const wrapper = shallowMount(InsuranceCompany, { + global: { + mocks: { + $store: store + }, + }, + }); + + expect(wrapper.vm.isCashParentAccountNumber()).toBe(true); + }); + + test('should return false when parentAccountNumber does not match CASH_PARENT_ACCOUNT_NUMBER', () => { + applicationConfig.CASH_PARENT_ACCOUNT_NUMBER = "12345"; + store.getters.order.payment.parentAccountNumber = '67890'; + const wrapper = shallowMount(InsuranceCompany, { + global: { + mocks: { + $store: store, + }, + }, + }); + + expect(wrapper.vm.isCashParentAccountNumber()).toBe(false); + }); + + test('should call navigateWithoutSaving with { isCashSelected: true } when forceCashSelection is true', () => { + const wrapper = shallowMount(InsuranceCompany, { + global: { + mocks: { + $store: store, + $router: mockRouter, + }, + mixins: [baseMixin], + }, + }); + + + wrapper.vm.backButtonAction(true); + expect(mockRouter.navigateWithoutSaving).toHaveBeenCalledWith( + wrapper.vm.navigationScenarios.CLICKED_BACK, + wrapper.vm.$route, + { isCashSelected: true } + ); + }); + + test('should call navigateWithoutSaving with no extra parameter when forceCashSelection is false', () => { + const wrapper = shallowMount(InsuranceCompany, { + global: { + mocks: { + $store: store, + $router: mockRouter, + }, + mixins: [baseMixin], + }, + }); + wrapper.vm.backButtonAction(false); + expect(mockRouter.navigateWithoutSaving).toHaveBeenCalledWith( + wrapper.vm.navigationScenarios.CLICKED_BACK, + wrapper.vm.$route + ); + }); +}); diff --git a/src/layouts/schedule/schedule.spec.js b/src/layouts/schedule/schedule.spec.js index 270da75f0..18e659ec5 100644 --- a/src/layouts/schedule/schedule.spec.js +++ b/src/layouts/schedule/schedule.spec.js @@ -7,6 +7,7 @@ import { getMountOptions } from "@/helpers/unit-test-helper.js"; import store from "@/store"; import router from "@/router"; import baseMixin from "../../mixins/base-mixin"; +import { experimentSettings } from "../../constants/experiments"; // Mock basemixin jest.mock("@/mixins/base-mixin.js", () => ({ @@ -177,6 +178,7 @@ beforeEach(() => { glassParts: [], supportingItems: [], }, + experimentSettings: {}, }; }); afterEach(() => { diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 63a2d7d64..0853664e2 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -18,7 +18,18 @@ marginTopSizeOverride="1" /> + selectableDate.date === this.selectedDate ); }, + isPricingByDayExperiment() { + return ( + experimentMixin.methods + .getSettingValue(experimentSettings.PRICING_BY_DAY) + ?.toLowerCase() === "true" + ); + }, }, methods: { splitCopyOnCMSPlaceHolder, @@ -537,6 +558,7 @@ export default { funnelSubHeader, Form, loadingModal, + datePicker, datePicker2, locationAlerts, timeSlotModalQuestion,