From 314193eb43a8fa102caaf4791729c6261333a956 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Tue, 28 Mar 2023 13:47:09 -0400 Subject: [PATCH] Updated existing unit tests --- src/digital-components/modal/modal.spec.js | 4 +- .../mobile-location-modal-questions.spec.js | 14 +++++++ .../service-location/service-location.spec.js | 14 +++++++ .../service-zip-modal-question.spec.js | 14 +++++++ .../modal-button-main.spec.js | 38 +++++++++---------- 5 files changed, 63 insertions(+), 21 deletions(-) diff --git a/src/digital-components/modal/modal.spec.js b/src/digital-components/modal/modal.spec.js index a948fe99a..e4d8692d4 100644 --- a/src/digital-components/modal/modal.spec.js +++ b/src/digital-components/modal/modal.spec.js @@ -92,7 +92,7 @@ describe("modal.vue", () => { wrapper.vm.resetButtonStyle = resetButtonStyle; // Act - const buttonMain = wrapper.findComponent({ ref: "buttonMain" }); + const buttonMain = wrapper.findComponent({ ref: "modalButtonMain" }); await buttonMain.trigger("click-event"); // Assert @@ -124,7 +124,7 @@ describe("modal.vue", () => { wrapper.vm.resetButtonStyle = resetButtonStyle; // Act - const buttonMain = wrapper.findComponent({ ref: "buttonMain" }); + const buttonMain = wrapper.findComponent({ ref: "modalButtonMain" }); await buttonMain.trigger("click-event"); // Assert diff --git a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js index fbea693b9..66bd93799 100644 --- a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js +++ b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.spec.js @@ -110,12 +110,26 @@ const mockGetPricedMobileFeePart = (mockServiceZipCode) => { return Promise.resolve(mobileFeePart); }; +const mockGetServiceabilityDetails = (mockServiceZipCode) => { + const serviceabilityDetails = { + isGlassServiceableInshop: true, + isRecalibrationServiceableInshop: true, + isGlassServiceableMobile: true, + isRecalibrationServiceableMobile: true, + }; + + return Promise.resolve(serviceabilityDetails); +}; + jest.mock( "@/layouts/service-location/helpers/service-location-helper/service-location-helper", () => ({ getPricedMobileFeePart: jest.fn((mockServiceZipCode) => { return mockGetPricedMobileFeePart(mockServiceZipCode); }), + getServiceabilityDetails: jest.fn((mockServiceZipCode) => { + return mockGetServiceabilityDetails(mockServiceZipCode); + }), }) ); diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index b48fa2f06..2a056c4d1 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -32,12 +32,26 @@ const mockGetPricedMobileFeePart = (mockServiceZipCode) => { return Promise.resolve(mobileFeePart); }; +const mockGetServiceabilityDetails = (mockServiceZipCode) => { + const serviceabilityDetails = { + isGlassServiceableInshop: true, + isRecalibrationServiceableInshop: true, + isGlassServiceableMobile: true, + isRecalibrationServiceableMobile: true, + }; + + return Promise.resolve(serviceabilityDetails); +}; + jest.mock( "@/layouts/service-location/helpers/service-location-helper/service-location-helper", () => ({ getPricedMobileFeePart: jest.fn((mockServiceZipCode) => { return mockGetPricedMobileFeePart(mockServiceZipCode); }), + getServiceabilityDetails: jest.fn((mockServiceZipCode) => { + return mockGetServiceabilityDetails(mockServiceZipCode); + }), }) ); diff --git a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.spec.js b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.spec.js index 407e129cf..6c9cf42f5 100644 --- a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.spec.js +++ b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.spec.js @@ -33,12 +33,26 @@ const mockGetPricedMobileFeePart = (mockServiceZipCode) => { return Promise.resolve(mobileFeePart); }; +const mockGetServiceabilityDetails = (mockServiceZipCode) => { + const serviceabilityDetails = { + isGlassServiceableInshop: true, + isRecalibrationServiceableInshop: true, + isGlassServiceableMobile: true, + isRecalibrationServiceableMobile: true, + }; + + return Promise.resolve(serviceabilityDetails); +}; + jest.mock( "@/layouts/service-location/helpers/service-location-helper/service-location-helper", () => ({ getPricedMobileFeePart: jest.fn((mockServiceZipCode) => { return mockGetPricedMobileFeePart(mockServiceZipCode); }), + getServiceabilityDetails: jest.fn((mockServiceZipCode) => { + return mockGetServiceabilityDetails(mockServiceZipCode); + }), }) ); diff --git a/src/ux-components/modal-button-main/modal-button-main.spec.js b/src/ux-components/modal-button-main/modal-button-main.spec.js index 41e244a72..bd3587f22 100644 --- a/src/ux-components/modal-button-main/modal-button-main.spec.js +++ b/src/ux-components/modal-button-main/modal-button-main.spec.js @@ -1,21 +1,21 @@ import { shallowMount } from "@vue/test-utils"; -import buttonMain from "./button-main"; +import modalButtonMain from "./modal-button-main"; import { getMountOptions } from "@/helpers/unit-test-helper.js"; import { nextTick } from "vue"; -describe("buttonMain.vue", () => { +describe("modal-button-main.vue", () => { it("Should return btn-primary class", () => { // Arrange/Act const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { isPrimary: true, }, }) ); const button = wrapper.find("button"); - + // Assert expect(button.attributes("class")).toContain("btn-primary"); }); @@ -23,9 +23,9 @@ describe("buttonMain.vue", () => { it("Should return aria-disabled state", () => { // Arrange/Act const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { isDisabled: true, }, }) @@ -39,9 +39,9 @@ describe("buttonMain.vue", () => { it("Should return loader color", async () => { // Arrange const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { loaderColor: "blue", loaderEnabled: true, }, @@ -60,9 +60,9 @@ describe("buttonMain.vue", () => { it("Should return loader position", async () => { // Arrange const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { loaderPosition: "right", loaderEnabled: true, }, @@ -81,9 +81,9 @@ describe("buttonMain.vue", () => { it("Should set 'isLoaderDisplayed' to false when calling 'removeLoader'", async () => { // Arrange const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { loaderPosition: "right", loaderEnabled: true, }, @@ -106,9 +106,9 @@ describe("buttonMain.vue", () => { it("Should set 'isLoaderDisplayed' to false when calling 'resetButtonStyle'", async () => { // Arrange const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { loaderPosition: "right", loaderEnabled: true, }, @@ -130,9 +130,9 @@ describe("buttonMain.vue", () => { it("Should emit 'click-event' event when clicking if the button is enabled", async () => { // Arrange const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { loaderPosition: "right", loaderEnabled: true, isDisabled: false, @@ -154,9 +154,9 @@ describe("buttonMain.vue", () => { it("Should not emit 'click-event' event when clicking if the button is disabled", async () => { // Arrange const wrapper = shallowMount( - buttonMain, + modalButtonMain, setupMocks({ - props: { + propsData: { loaderPosition: "right", loaderEnabled: true, isDisabled: true,