From 9be65c0c819b0defb54363406d66c0ae4716b953 Mon Sep 17 00:00:00 2001 From: Kroell Date: Fri, 6 Jan 2023 14:22:54 -0500 Subject: [PATCH] unit test to check page prereqs --- .../license-plate-lookup.spec.js | 41 ++++++++----------- .../license-plate-lookup.vue | 23 ++--------- 2 files changed, 21 insertions(+), 43 deletions(-) diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.spec.js b/src/layouts/license-plate-lookup/license-plate-lookup.spec.js index fdb41019..d367826d 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.spec.js +++ b/src/layouts/license-plate-lookup/license-plate-lookup.spec.js @@ -32,30 +32,23 @@ jest.mock("@/helpers/damage-helper", () => ({ })); describe("license-plate-lookup.vue", () => { - describe("navigation", () => { - test("backButtonAction triggers a router.navigate change", async () => { - //Arrange - const { wrapper } = setupMocks({}); + test("Make set, arePagePrerequisitesValid should be true ", () => { + //Arrange + const { wrapper } = setupMocks({}); + useMainStore().order.vehicle.carId = "CR00000395"; - //Act - licensePlateLookup.beforeRouteEnter.call( - wrapper.vm, - { query: { issPage: "license-plate-lookup" } }, - undefined, - (c) => c(wrapper.vm) - ); - - wrapper.vm.backButtonAction(); - - //Assert - expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); - }); - - // TODO: Test - Continue button should call forwardButtonAction when data entered matches data from store - - // TODO: Test - Methods to get values from the store (license plate, registration zip) + //Act + licensePlateLookup.beforeRouteEnter.call( + wrapper.vm, + { query: { issPage: "license-plate-lookup" } }, + undefined, + (c) => c(wrapper.vm) + ); + let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); + //Assert + expect(arePagePrerequisitesValid).toBe(true); }); }); @@ -63,13 +56,13 @@ function setupMocks({ licensePlateQuestionCmsContent = {}, licensePlateQuestionInitialData = {}, pageHeaderWidgetHeaderText = {}, + pageFooterWidgetCmsContent = {}, mountOptionsMockData = {}, - partsOrQuestions = [], //Values to set in the state store carId = null, registrationZipCode = null, licensePlate = null, //"TESTPLATE", - emailAddress = null, //"test@test.com", + }) { //Mock api responses const apiResponses = { @@ -84,6 +77,8 @@ function setupMocks({ LogoImage: "https://digitalisscms.dev.safelite.io/images/default-source/default-album/logos/insuranceLogo.jpg", }, + SiteFooterWidget: pageFooterWidgetCmsContent, + }, licensePlateQuestionInitialData: licensePlateQuestionInitialData, }; diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue index b93a69d6..6be4545f 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.vue +++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue @@ -20,8 +20,7 @@ @back-clicked="backButtonAction" @forward-clicked="forwardButtonAction" ref="siteFooter" - :is-forward-action-disabled="!meta.valid" /> - + :is-forward-action-disabled="isForwardActionDisabled" /> @@ -52,30 +51,14 @@ export default { name: 'license-plate-lookup', mixins: [BaseFormMixin], components: { -<<<<<<< HEAD - VeeValidateForm: Form, + Form, siteFooter, siteHeader, siteSubHeader, vehicleBanner, textboxQuestion, LicensePlateQuestion, -<<<<<<< HEAD - ZipQuestion, - LicensePlateLookupAlerts, - }, - setup() { - const mainStore = useMainStore(); -======= ZipQuestion, -======= - Form, - SiteFooter, - SiteHeader, - SiteSubHeader, - VehicleBanner, ->>>>>>> c55f3731be77a48139e06899a0ce08cb157b91fd ->>>>>>> develop }, data() { return { @@ -108,7 +91,7 @@ export default { }); }, methods: { - arePagePrerequisiteValid() { + arePagePrerequisitesValid() { if (this.mainStore.order.vehicle.carId) { return true; }