From 6cba28d4942a24d1de52ad5d3c601d6efd1078ce Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Thu, 6 Jul 2023 14:48:58 -0400 Subject: [PATCH] Customer Details page tests partially if not completely, finished --- .../customer-details/customer-details.spec.js | 59 ++++++++++++++++++- .../customer-details/customer-details.vue | 4 +- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/layouts/customer-details/customer-details.spec.js b/src/layouts/customer-details/customer-details.spec.js index 3d0843e10..2014f47d3 100644 --- a/src/layouts/customer-details/customer-details.spec.js +++ b/src/layouts/customer-details/customer-details.spec.js @@ -1 +1,58 @@ -test.todo("some test to be written in the future"); +// Components +import customerDetails from "@/layouts/customer-details/customer-details.vue"; + +// Supporting Files +import { shallowMount } from "@vue/test-utils"; +import { getMountOptions } from "@/helpers/unit-test-helper.js"; +import * as navigateToHeritage from "@/helpers/heritage-integration/navigation-helper"; + +jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({ + navigateToHeritageFunnel: jest.fn(), +})); + +// Mock our module for promises. +jest.mock("@/helpers/layout-helper.js", () => ({ + settleAllPromises: jest.fn(), +})); + +describe("customer-details.vue", () => { + describe("navigation", () => { + test("if the back button is clicked, navigate back", async () => { + // Arrange + const { wrapper } = setupMocks(); + + // Act + await wrapper.vm.backButtonAction(); + + // Assert + expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled(); + }); + + test("if the continue button is clicked, navigate forward", async () => { + // Arrange + const { wrapper } = setupMocks(); + + // Act + await wrapper.vm.forwardButtonAction(); + + // Assert + expect(navigateToHeritage.navigateToHeritageFunnel).toHaveBeenCalled(); + }); + }); +}); + +function setupMocks() { + const wrapper = shallowMount( + customerDetails, + getMountOptions({ + router: { + navigate: jest.fn(), + navigate: jest.fn(), + navigateWithSaving: jest.fn(), + navigateWithoutSaving: jest.fn(), + }, + }) + ); + + 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 4377050e2..f3b039ee8 100644 --- a/src/layouts/customer-details/customer-details.vue +++ b/src/layouts/customer-details/customer-details.vue @@ -8,14 +8,14 @@ cmsWidgetName="FirstNameWidget" v-model="firstName" ref="firstName" - inputId="08497a2efd9a4a73a70360ab47b4838d" + customInputId="firstName" validationRules="first-name-required" />