Updated existing unit tests
This commit is contained in:
parent
0bde42e0d2
commit
314193eb43
5 changed files with 63 additions and 21 deletions
|
|
@ -92,7 +92,7 @@ describe("modal.vue", () => {
|
||||||
wrapper.vm.resetButtonStyle = resetButtonStyle;
|
wrapper.vm.resetButtonStyle = resetButtonStyle;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const buttonMain = wrapper.findComponent({ ref: "buttonMain" });
|
const buttonMain = wrapper.findComponent({ ref: "modalButtonMain" });
|
||||||
await buttonMain.trigger("click-event");
|
await buttonMain.trigger("click-event");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
@ -124,7 +124,7 @@ describe("modal.vue", () => {
|
||||||
wrapper.vm.resetButtonStyle = resetButtonStyle;
|
wrapper.vm.resetButtonStyle = resetButtonStyle;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const buttonMain = wrapper.findComponent({ ref: "buttonMain" });
|
const buttonMain = wrapper.findComponent({ ref: "modalButtonMain" });
|
||||||
await buttonMain.trigger("click-event");
|
await buttonMain.trigger("click-event");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
|
||||||
|
|
@ -110,12 +110,26 @@ const mockGetPricedMobileFeePart = (mockServiceZipCode) => {
|
||||||
return Promise.resolve(mobileFeePart);
|
return Promise.resolve(mobileFeePart);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mockGetServiceabilityDetails = (mockServiceZipCode) => {
|
||||||
|
const serviceabilityDetails = {
|
||||||
|
isGlassServiceableInshop: true,
|
||||||
|
isRecalibrationServiceableInshop: true,
|
||||||
|
isGlassServiceableMobile: true,
|
||||||
|
isRecalibrationServiceableMobile: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Promise.resolve(serviceabilityDetails);
|
||||||
|
};
|
||||||
|
|
||||||
jest.mock(
|
jest.mock(
|
||||||
"@/layouts/service-location/helpers/service-location-helper/service-location-helper",
|
"@/layouts/service-location/helpers/service-location-helper/service-location-helper",
|
||||||
() => ({
|
() => ({
|
||||||
getPricedMobileFeePart: jest.fn((mockServiceZipCode) => {
|
getPricedMobileFeePart: jest.fn((mockServiceZipCode) => {
|
||||||
return mockGetPricedMobileFeePart(mockServiceZipCode);
|
return mockGetPricedMobileFeePart(mockServiceZipCode);
|
||||||
}),
|
}),
|
||||||
|
getServiceabilityDetails: jest.fn((mockServiceZipCode) => {
|
||||||
|
return mockGetServiceabilityDetails(mockServiceZipCode);
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,26 @@ const mockGetPricedMobileFeePart = (mockServiceZipCode) => {
|
||||||
return Promise.resolve(mobileFeePart);
|
return Promise.resolve(mobileFeePart);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mockGetServiceabilityDetails = (mockServiceZipCode) => {
|
||||||
|
const serviceabilityDetails = {
|
||||||
|
isGlassServiceableInshop: true,
|
||||||
|
isRecalibrationServiceableInshop: true,
|
||||||
|
isGlassServiceableMobile: true,
|
||||||
|
isRecalibrationServiceableMobile: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Promise.resolve(serviceabilityDetails);
|
||||||
|
};
|
||||||
|
|
||||||
jest.mock(
|
jest.mock(
|
||||||
"@/layouts/service-location/helpers/service-location-helper/service-location-helper",
|
"@/layouts/service-location/helpers/service-location-helper/service-location-helper",
|
||||||
() => ({
|
() => ({
|
||||||
getPricedMobileFeePart: jest.fn((mockServiceZipCode) => {
|
getPricedMobileFeePart: jest.fn((mockServiceZipCode) => {
|
||||||
return mockGetPricedMobileFeePart(mockServiceZipCode);
|
return mockGetPricedMobileFeePart(mockServiceZipCode);
|
||||||
}),
|
}),
|
||||||
|
getServiceabilityDetails: jest.fn((mockServiceZipCode) => {
|
||||||
|
return mockGetServiceabilityDetails(mockServiceZipCode);
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,26 @@ const mockGetPricedMobileFeePart = (mockServiceZipCode) => {
|
||||||
return Promise.resolve(mobileFeePart);
|
return Promise.resolve(mobileFeePart);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mockGetServiceabilityDetails = (mockServiceZipCode) => {
|
||||||
|
const serviceabilityDetails = {
|
||||||
|
isGlassServiceableInshop: true,
|
||||||
|
isRecalibrationServiceableInshop: true,
|
||||||
|
isGlassServiceableMobile: true,
|
||||||
|
isRecalibrationServiceableMobile: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Promise.resolve(serviceabilityDetails);
|
||||||
|
};
|
||||||
|
|
||||||
jest.mock(
|
jest.mock(
|
||||||
"@/layouts/service-location/helpers/service-location-helper/service-location-helper",
|
"@/layouts/service-location/helpers/service-location-helper/service-location-helper",
|
||||||
() => ({
|
() => ({
|
||||||
getPricedMobileFeePart: jest.fn((mockServiceZipCode) => {
|
getPricedMobileFeePart: jest.fn((mockServiceZipCode) => {
|
||||||
return mockGetPricedMobileFeePart(mockServiceZipCode);
|
return mockGetPricedMobileFeePart(mockServiceZipCode);
|
||||||
}),
|
}),
|
||||||
|
getServiceabilityDetails: jest.fn((mockServiceZipCode) => {
|
||||||
|
return mockGetServiceabilityDetails(mockServiceZipCode);
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
import { shallowMount } from "@vue/test-utils";
|
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 { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
import { nextTick } from "vue";
|
import { nextTick } from "vue";
|
||||||
|
|
||||||
describe("buttonMain.vue", () => {
|
describe("modal-button-main.vue", () => {
|
||||||
it("Should return btn-primary class", () => {
|
it("Should return btn-primary class", () => {
|
||||||
// Arrange/Act
|
// Arrange/Act
|
||||||
const wrapper = shallowMount(
|
const wrapper = shallowMount(
|
||||||
buttonMain,
|
modalButtonMain,
|
||||||
setupMocks({
|
setupMocks({
|
||||||
props: {
|
propsData: {
|
||||||
isPrimary: true,
|
isPrimary: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
const button = wrapper.find("button");
|
const button = wrapper.find("button");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(button.attributes("class")).toContain("btn-primary");
|
expect(button.attributes("class")).toContain("btn-primary");
|
||||||
});
|
});
|
||||||
|
|
@ -23,9 +23,9 @@ describe("buttonMain.vue", () => {
|
||||||
it("Should return aria-disabled state", () => {
|
it("Should return aria-disabled state", () => {
|
||||||
// Arrange/Act
|
// Arrange/Act
|
||||||
const wrapper = shallowMount(
|
const wrapper = shallowMount(
|
||||||
buttonMain,
|
modalButtonMain,
|
||||||
setupMocks({
|
setupMocks({
|
||||||
props: {
|
propsData: {
|
||||||
isDisabled: true,
|
isDisabled: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
@ -39,9 +39,9 @@ describe("buttonMain.vue", () => {
|
||||||
it("Should return loader color", async () => {
|
it("Should return loader color", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const wrapper = shallowMount(
|
const wrapper = shallowMount(
|
||||||
buttonMain,
|
modalButtonMain,
|
||||||
setupMocks({
|
setupMocks({
|
||||||
props: {
|
propsData: {
|
||||||
loaderColor: "blue",
|
loaderColor: "blue",
|
||||||
loaderEnabled: true,
|
loaderEnabled: true,
|
||||||
},
|
},
|
||||||
|
|
@ -60,9 +60,9 @@ describe("buttonMain.vue", () => {
|
||||||
it("Should return loader position", async () => {
|
it("Should return loader position", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const wrapper = shallowMount(
|
const wrapper = shallowMount(
|
||||||
buttonMain,
|
modalButtonMain,
|
||||||
setupMocks({
|
setupMocks({
|
||||||
props: {
|
propsData: {
|
||||||
loaderPosition: "right",
|
loaderPosition: "right",
|
||||||
loaderEnabled: true,
|
loaderEnabled: true,
|
||||||
},
|
},
|
||||||
|
|
@ -81,9 +81,9 @@ describe("buttonMain.vue", () => {
|
||||||
it("Should set 'isLoaderDisplayed' to false when calling 'removeLoader'", async () => {
|
it("Should set 'isLoaderDisplayed' to false when calling 'removeLoader'", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const wrapper = shallowMount(
|
const wrapper = shallowMount(
|
||||||
buttonMain,
|
modalButtonMain,
|
||||||
setupMocks({
|
setupMocks({
|
||||||
props: {
|
propsData: {
|
||||||
loaderPosition: "right",
|
loaderPosition: "right",
|
||||||
loaderEnabled: true,
|
loaderEnabled: true,
|
||||||
},
|
},
|
||||||
|
|
@ -106,9 +106,9 @@ describe("buttonMain.vue", () => {
|
||||||
it("Should set 'isLoaderDisplayed' to false when calling 'resetButtonStyle'", async () => {
|
it("Should set 'isLoaderDisplayed' to false when calling 'resetButtonStyle'", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const wrapper = shallowMount(
|
const wrapper = shallowMount(
|
||||||
buttonMain,
|
modalButtonMain,
|
||||||
setupMocks({
|
setupMocks({
|
||||||
props: {
|
propsData: {
|
||||||
loaderPosition: "right",
|
loaderPosition: "right",
|
||||||
loaderEnabled: true,
|
loaderEnabled: true,
|
||||||
},
|
},
|
||||||
|
|
@ -130,9 +130,9 @@ describe("buttonMain.vue", () => {
|
||||||
it("Should emit 'click-event' event when clicking if the button is enabled", async () => {
|
it("Should emit 'click-event' event when clicking if the button is enabled", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const wrapper = shallowMount(
|
const wrapper = shallowMount(
|
||||||
buttonMain,
|
modalButtonMain,
|
||||||
setupMocks({
|
setupMocks({
|
||||||
props: {
|
propsData: {
|
||||||
loaderPosition: "right",
|
loaderPosition: "right",
|
||||||
loaderEnabled: true,
|
loaderEnabled: true,
|
||||||
isDisabled: false,
|
isDisabled: false,
|
||||||
|
|
@ -154,9 +154,9 @@ describe("buttonMain.vue", () => {
|
||||||
it("Should not emit 'click-event' event when clicking if the button is disabled", async () => {
|
it("Should not emit 'click-event' event when clicking if the button is disabled", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const wrapper = shallowMount(
|
const wrapper = shallowMount(
|
||||||
buttonMain,
|
modalButtonMain,
|
||||||
setupMocks({
|
setupMocks({
|
||||||
props: {
|
propsData: {
|
||||||
loaderPosition: "right",
|
loaderPosition: "right",
|
||||||
loaderEnabled: true,
|
loaderEnabled: true,
|
||||||
isDisabled: true,
|
isDisabled: true,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue