Fixed unit tests
This commit is contained in:
parent
a1f818ccd6
commit
01e46e2abc
2 changed files with 106 additions and 54 deletions
|
|
@ -260,7 +260,11 @@ describe("service-location.vue", () => {
|
||||||
const { wrapper } = setupMocks({
|
const { wrapper } = setupMocks({
|
||||||
mixins: [mockMixin],
|
mixins: [mockMixin],
|
||||||
});
|
});
|
||||||
wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn();
|
|
||||||
|
const mobileLocationQuestionsComponent = wrapper.findComponent({
|
||||||
|
ref: "mobileLocationQuestions",
|
||||||
|
});
|
||||||
|
mobileLocationQuestionsComponent.resetComponent = jest.fn();
|
||||||
|
|
||||||
const newServiceZipCodeQuestion = {
|
const newServiceZipCodeQuestion = {
|
||||||
zipCode: "61606",
|
zipCode: "61606",
|
||||||
|
|
@ -281,8 +285,16 @@ describe("service-location.vue", () => {
|
||||||
test("resets mobile location when service zip code is updated", () => {
|
test("resets mobile location when service zip code is updated", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn();
|
|
||||||
wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn();
|
const mobileLocationQuestionsComponent = wrapper.findComponent({
|
||||||
|
ref: "mobileLocationQuestions",
|
||||||
|
});
|
||||||
|
mobileLocationQuestionsComponent.resetComponent = jest.fn();
|
||||||
|
|
||||||
|
const serviceZipCodeComponent = wrapper.findComponent({
|
||||||
|
ref: "serviceZipCodeQuestion",
|
||||||
|
});
|
||||||
|
serviceZipCodeComponent.resetMobileFeePart = jest.fn();
|
||||||
|
|
||||||
const newServiceZipCodeQuestion = {
|
const newServiceZipCodeQuestion = {
|
||||||
zipCode: "61606",
|
zipCode: "61606",
|
||||||
|
|
@ -312,10 +324,6 @@ describe("service-location.vue", () => {
|
||||||
isVehicleProtected: null,
|
isVehicleProtected: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const serviceZipCodeComponent = wrapper.findComponent({
|
|
||||||
ref: "serviceZipCodeQuestion",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
serviceZipCodeComponent.vm.$emit("update:modelValue", newServiceZipCodeQuestion);
|
serviceZipCodeComponent.vm.$emit("update:modelValue", newServiceZipCodeQuestion);
|
||||||
|
|
||||||
|
|
@ -326,8 +334,16 @@ describe("service-location.vue", () => {
|
||||||
test("resets appointment type selection when service zip code is updated by service zip modal", () => {
|
test("resets appointment type selection when service zip code is updated by service zip modal", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn();
|
|
||||||
wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn();
|
const mobileLocationQuestionsComponent = wrapper.findComponent({
|
||||||
|
ref: "mobileLocationQuestions",
|
||||||
|
});
|
||||||
|
mobileLocationQuestionsComponent.resetComponent = jest.fn();
|
||||||
|
|
||||||
|
const serviceZipCodeComponent = wrapper.findComponent({
|
||||||
|
ref: "serviceZipCodeQuestion",
|
||||||
|
});
|
||||||
|
serviceZipCodeComponent.resetMobileFeePart = jest.fn();
|
||||||
|
|
||||||
const newServiceZipCodeQuestion = {
|
const newServiceZipCodeQuestion = {
|
||||||
zipCode: "61606",
|
zipCode: "61606",
|
||||||
|
|
@ -336,10 +352,6 @@ describe("service-location.vue", () => {
|
||||||
|
|
||||||
wrapper.vm.selectedAppointmentType = "Inshop";
|
wrapper.vm.selectedAppointmentType = "Inshop";
|
||||||
|
|
||||||
const serviceZipCodeComponent = wrapper.findComponent({
|
|
||||||
ref: "serviceZipCodeQuestion",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
serviceZipCodeComponent.vm.$emit("update:modelValue", newServiceZipCodeQuestion);
|
serviceZipCodeComponent.vm.$emit("update:modelValue", newServiceZipCodeQuestion);
|
||||||
|
|
||||||
|
|
@ -350,7 +362,17 @@ describe("service-location.vue", () => {
|
||||||
test("displays military zip message when zip is updated", () => {
|
test("displays military zip message when zip is updated", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn();
|
|
||||||
|
const mobileLocationQuestionsComponent = wrapper.findComponent({
|
||||||
|
ref: "mobileLocationQuestions",
|
||||||
|
});
|
||||||
|
mobileLocationQuestionsComponent.resetComponent = jest.fn();
|
||||||
|
|
||||||
|
const serviceZipCodeComponent = wrapper.findComponent({
|
||||||
|
ref: "serviceZipCodeQuestion",
|
||||||
|
});
|
||||||
|
serviceZipCodeComponent.resetMobileFeePart = jest.fn();
|
||||||
|
|
||||||
expect(wrapper.vm.zipContainsMilitaryBase).toBe(false);
|
expect(wrapper.vm.zipContainsMilitaryBase).toBe(false);
|
||||||
|
|
||||||
const newServiceZipCodeQuestion = {
|
const newServiceZipCodeQuestion = {
|
||||||
|
|
@ -358,10 +380,6 @@ describe("service-location.vue", () => {
|
||||||
state: "OH",
|
state: "OH",
|
||||||
};
|
};
|
||||||
|
|
||||||
const serviceZipCodeComponent = wrapper.findComponent({
|
|
||||||
ref: "serviceZipCodeQuestion",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
serviceZipCodeComponent.vm.$emit("updated-contains-military-base", true);
|
serviceZipCodeComponent.vm.$emit("updated-contains-military-base", true);
|
||||||
|
|
||||||
|
|
@ -371,10 +389,23 @@ describe("service-location.vue", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("updating mobile location", () => {
|
describe("updating mobile location", () => {
|
||||||
test("updates the page model after providing the mobile location", () => {
|
test("updates the page model after providing the mobile location", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn();
|
|
||||||
|
await wrapper.setData({
|
||||||
|
selectedAppointmentType: "Mobile",
|
||||||
|
});
|
||||||
|
|
||||||
|
const mobileLocationQuestionsComponent = wrapper.findComponent({
|
||||||
|
ref: "mobileLocationQuestions",
|
||||||
|
});
|
||||||
|
mobileLocationQuestionsComponent.resetComponent = jest.fn();
|
||||||
|
|
||||||
|
const serviceZipCodeComponent = wrapper.findComponent({
|
||||||
|
ref: "serviceZipCodeQuestion",
|
||||||
|
});
|
||||||
|
serviceZipCodeComponent.resetMobileFeePart = jest.fn();
|
||||||
|
|
||||||
const mobileLocationQuestions = {
|
const mobileLocationQuestions = {
|
||||||
addressQuestions: {
|
addressQuestions: {
|
||||||
|
|
@ -399,12 +430,11 @@ describe("service-location.vue", () => {
|
||||||
isVehicleProtected: true,
|
isVehicleProtected: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mobileLocationComponent = wrapper.findComponent({
|
|
||||||
ref: "mobileLocationModalQuestions",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
mobileLocationComponent.vm.$emit("update:modelValue", newMobileLocationQuestions);
|
mobileLocationQuestionsComponent.vm.$emit(
|
||||||
|
"update:modelValue",
|
||||||
|
newMobileLocationQuestions
|
||||||
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.mobileLocationQuestions).toStrictEqual(newMobileLocationQuestions);
|
expect(wrapper.vm.mobileLocationQuestions).toStrictEqual(newMobileLocationQuestions);
|
||||||
|
|
@ -413,8 +443,20 @@ describe("service-location.vue", () => {
|
||||||
test("resets service zip code when mobile location is updated", async () => {
|
test("resets service zip code when mobile location is updated", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn();
|
|
||||||
wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn();
|
await wrapper.setData({
|
||||||
|
selectedAppointmentType: "Mobile",
|
||||||
|
});
|
||||||
|
|
||||||
|
const mobileLocationQuestionsComponent = wrapper.findComponent({
|
||||||
|
ref: "mobileLocationQuestions",
|
||||||
|
});
|
||||||
|
mobileLocationQuestionsComponent.resetComponent = jest.fn();
|
||||||
|
|
||||||
|
const serviceZipCodeComponent = wrapper.findComponent({
|
||||||
|
ref: "serviceZipCodeQuestion",
|
||||||
|
});
|
||||||
|
serviceZipCodeComponent.resetMobileFeePart = jest.fn();
|
||||||
|
|
||||||
const mobileLocationQuestions = {
|
const mobileLocationQuestions = {
|
||||||
addressQuestions: {
|
addressQuestions: {
|
||||||
|
|
@ -441,10 +483,6 @@ describe("service-location.vue", () => {
|
||||||
mobileFeePart: null,
|
mobileFeePart: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mobileLocationComponent = wrapper.findComponent({
|
|
||||||
ref: "mobileLocationModalQuestions",
|
|
||||||
});
|
|
||||||
|
|
||||||
wrapper.vm.serviceZipCodeQuestion = {
|
wrapper.vm.serviceZipCodeQuestion = {
|
||||||
zipCode: "61606",
|
zipCode: "61606",
|
||||||
state: "IL",
|
state: "IL",
|
||||||
|
|
@ -456,29 +494,38 @@ describe("service-location.vue", () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
mobileLocationComponent.vm.$emit("update:modelValue", newMobileLocationQuestions);
|
mobileLocationQuestionsComponent.vm.$emit(
|
||||||
|
"update:modelValue",
|
||||||
|
newMobileLocationQuestions
|
||||||
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.serviceZipCodeQuestion).toStrictEqual(newServiceZipCodeInfo);
|
expect(wrapper.vm.serviceZipCodeQuestion).toStrictEqual(newServiceZipCodeInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("resets appointment type selection when service zip code is updated by mobile location modal when Mobile is not selected", () => {
|
test("resets appointment type selection when service zip code is updated by mobile location modal when Mobile is not selected", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn();
|
|
||||||
wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn();
|
await wrapper.setData({
|
||||||
|
selectedAppointmentType: "Dropoff",
|
||||||
|
});
|
||||||
|
|
||||||
|
const mobileLocationQuestionsComponent = wrapper.findComponent({
|
||||||
|
ref: "mobileLocationQuestions",
|
||||||
|
});
|
||||||
|
mobileLocationQuestionsComponent.resetComponent = jest.fn();
|
||||||
|
|
||||||
|
const serviceZipCodeComponent = wrapper.findComponent({
|
||||||
|
ref: "serviceZipCodeQuestion",
|
||||||
|
});
|
||||||
|
serviceZipCodeComponent.resetMobileFeePart = jest.fn();
|
||||||
|
|
||||||
const newServiceZipCodeQuestion = {
|
const newServiceZipCodeQuestion = {
|
||||||
zipCode: "61606",
|
zipCode: "61606",
|
||||||
state: "IL",
|
state: "IL",
|
||||||
};
|
};
|
||||||
|
|
||||||
wrapper.vm.selectedAppointmentType = "Dropoff";
|
|
||||||
|
|
||||||
const serviceZipCodeComponent = wrapper.findComponent({
|
|
||||||
ref: "serviceZipCodeQuestion",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
serviceZipCodeComponent.vm.$emit("update:modelValue", newServiceZipCodeQuestion);
|
serviceZipCodeComponent.vm.$emit("update:modelValue", newServiceZipCodeQuestion);
|
||||||
|
|
||||||
|
|
@ -486,12 +533,23 @@ describe("service-location.vue", () => {
|
||||||
expect(wrapper.vm.selectedAppointmentType).toStrictEqual(null);
|
expect(wrapper.vm.selectedAppointmentType).toStrictEqual(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("does not reset appointment type selection when service zip code is updated by mobile location modal when Mobile is selected", () => {
|
test("does not reset appointment type selection when service zip code is updated by mobile location modal when Mobile is selected", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
const appointmentTypeMobile = "Mobile";
|
|
||||||
wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn();
|
await wrapper.setData({
|
||||||
wrapper.vm.$refs.serviceZipCodeQuestion.resetMobileFeePart = jest.fn();
|
selectedAppointmentType: "Mobile",
|
||||||
|
});
|
||||||
|
|
||||||
|
const mobileLocationQuestionsComponent = wrapper.findComponent({
|
||||||
|
ref: "mobileLocationQuestions",
|
||||||
|
});
|
||||||
|
mobileLocationQuestionsComponent.resetComponent = jest.fn();
|
||||||
|
|
||||||
|
const serviceZipCodeComponent = wrapper.findComponent({
|
||||||
|
ref: "serviceZipCodeQuestion",
|
||||||
|
});
|
||||||
|
serviceZipCodeComponent.resetMobileFeePart = jest.fn();
|
||||||
|
|
||||||
const mobileLocationQuestions = {
|
const mobileLocationQuestions = {
|
||||||
addressQuestions: {
|
addressQuestions: {
|
||||||
|
|
@ -504,17 +562,11 @@ describe("service-location.vue", () => {
|
||||||
isVehicleProtected: "YesAnswer",
|
isVehicleProtected: "YesAnswer",
|
||||||
};
|
};
|
||||||
|
|
||||||
wrapper.vm.selectedAppointmentType = "Mobile";
|
|
||||||
|
|
||||||
const mobileLocationComponent = wrapper.findComponent({
|
|
||||||
ref: "mobileLocationModalQuestions",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
mobileLocationComponent.vm.$emit("update:modelValue", mobileLocationQuestions);
|
mobileLocationQuestionsComponent.vm.$emit("update:modelValue", mobileLocationQuestions);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.selectedAppointmentType).toStrictEqual(appointmentTypeMobile);
|
expect(wrapper.vm.selectedAppointmentType).toStrictEqual("Mobile");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
@updated-serviceability="setServiceabilityDetails"
|
@updated-serviceability="setServiceabilityDetails"
|
||||||
@updated-contains-military-base="setContainsMilitaryBase"
|
@updated-contains-military-base="setContainsMilitaryBase"
|
||||||
validationRules="mobile-location-required"
|
validationRules="mobile-location-required"
|
||||||
ref="mobileLocationModalQuestions"
|
ref="mobileLocationQuestions"
|
||||||
linkWidgetName="MobileLocationLinkWidget"
|
linkWidgetName="MobileLocationLinkWidget"
|
||||||
modalWidgetName="MobileLocationModalWidget" />
|
modalWidgetName="MobileLocationModalWidget" />
|
||||||
<contentGroupModal ref="RecalModal" cmsWidgetName="RecalModal" />
|
<contentGroupModal ref="RecalModal" cmsWidgetName="RecalModal" />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue