Add tests for serviceZipCodeInfo and serviceLocation save methods
This commit is contained in:
parent
f30527c64f
commit
74af79a8f3
1 changed files with 314 additions and 0 deletions
|
|
@ -936,6 +936,84 @@ describe("Actions", () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("saveServiceZipCodeInfo, should call mutation and save zip code to state", () => {
|
||||
// Arrange
|
||||
const context = state;
|
||||
const commit = jest.fn();
|
||||
context.commit = commit;
|
||||
|
||||
const serviceZipCodeInfo = {
|
||||
zipCode: "43212",
|
||||
};
|
||||
|
||||
// Act
|
||||
actions.saveServiceLocation(context, serviceZipCodeInfo);
|
||||
|
||||
// Assert
|
||||
expect(commit).toBeCalledWith(storeMutations.UPDATE_SERVICE_LOCATION, serviceZipCodeInfo);
|
||||
expect(state.order.serviceLocation.zipCode).toEqual("43212");
|
||||
});
|
||||
|
||||
it("saveServiceZipCodeInfo, should reset if zip code is different", () => {
|
||||
// Arrange
|
||||
const context = {
|
||||
state: {
|
||||
order: {
|
||||
serviceLocation: {
|
||||
zipCode: "43212",
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const commit = jest.fn();
|
||||
const dispatch = jest.fn();
|
||||
|
||||
context.commit = commit;
|
||||
context.dispatch = dispatch;
|
||||
|
||||
const serviceZipCodeInfo = {
|
||||
zipCode: "43202",
|
||||
};
|
||||
|
||||
// Act
|
||||
actions.saveServiceZipCodeInfo(context, serviceZipCodeInfo);
|
||||
|
||||
// Assert
|
||||
expect(dispatch).toHaveBeenCalledWith(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES);
|
||||
expect(commit).toHaveBeenCalledWith(storeMutations.RESET_SERVICE_LOCATION_MOBILE_ADDRESS);
|
||||
});
|
||||
|
||||
it("saveServiceZipCodeInfo, should not reset if zip code is the same", () => {
|
||||
// Arrange
|
||||
const context = {
|
||||
state: {
|
||||
order: {
|
||||
serviceLocation: {
|
||||
zipCode: "43212",
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const commit = jest.fn();
|
||||
const dispatch = jest.fn();
|
||||
|
||||
context.commit = commit;
|
||||
context.dispatch = dispatch;
|
||||
|
||||
const serviceZipCodeInfo = {
|
||||
zipCode: "43212",
|
||||
};
|
||||
|
||||
// Act
|
||||
actions.saveServiceZipCodeInfo(context, serviceZipCodeInfo);
|
||||
|
||||
// Assert
|
||||
expect(dispatch).not.toHaveBeenCalledWith(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES);
|
||||
expect(commit).not.toHaveBeenCalledWith(storeMutations.RESET_SERVICE_LOCATION_MOBILE_ADDRESS);
|
||||
});
|
||||
|
||||
it("saveServiceLocation, should call mutation and save service address to state", () => {
|
||||
// Arrange
|
||||
const context = state;
|
||||
|
|
@ -962,6 +1040,242 @@ describe("Actions", () => {
|
|||
expect(state.order.serviceLocation.zipCodeCtu).toEqual("01820");
|
||||
});
|
||||
|
||||
it("saveServiceLocation, should reset if zipcode is different", () => {
|
||||
// Arrange
|
||||
const context = {
|
||||
state: {
|
||||
order: {
|
||||
serviceLocation: {
|
||||
address: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
zipCode: "43212",
|
||||
state: "OH",
|
||||
zipCodeCtu: "01820",
|
||||
appointmentType: "Mobile",
|
||||
isVehicleProtected: true,
|
||||
provider: {
|
||||
providerNumber: "11111",
|
||||
address: {
|
||||
streetAddress: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
state: "OH",
|
||||
zip: "43212",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const commit = jest.fn();
|
||||
const dispatch = jest.fn();
|
||||
|
||||
context.commit = commit;
|
||||
context.dispatch = dispatch;
|
||||
|
||||
const serviceLocation = {
|
||||
address: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
zipCode: "43202",
|
||||
state: "OH",
|
||||
zipCodeCtu: "01820",
|
||||
appointmentType: "Mobile",
|
||||
isVehicleProtected: true,
|
||||
provider: {
|
||||
providerNumber: "11111",
|
||||
address: {
|
||||
streetAddress: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
state: "OH",
|
||||
zip: "43212",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Act
|
||||
actions.saveServiceLocation(context, serviceLocation);
|
||||
|
||||
// Assert
|
||||
expect(commit).toHaveBeenCalledWith(storeMutations.RESET_SCHEDULE);
|
||||
});
|
||||
|
||||
it("saveServiceLocation, should reset if provider is different", () => {
|
||||
// Arrange
|
||||
const context = {
|
||||
state: {
|
||||
order: {
|
||||
serviceLocation: {
|
||||
address: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
zipCode: "43212",
|
||||
state: "OH",
|
||||
zipCodeCtu: "01820",
|
||||
appointmentType: "Mobile",
|
||||
isVehicleProtected: true,
|
||||
provider: {
|
||||
providerNumber: "11111",
|
||||
address: {
|
||||
streetAddress: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
state: "OH",
|
||||
zip: "43212",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const commit = jest.fn();
|
||||
const dispatch = jest.fn();
|
||||
|
||||
context.commit = commit;
|
||||
context.dispatch = dispatch;
|
||||
|
||||
const serviceLocation = {
|
||||
address: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
zipCode: "43212",
|
||||
state: "OH",
|
||||
zipCodeCtu: "01820",
|
||||
appointmentType: "Mobile",
|
||||
isVehicleProtected: true,
|
||||
provider: {
|
||||
providerNumber: "22222",
|
||||
address: {
|
||||
streetAddress: "321 Test Lane",
|
||||
city: "Columbus",
|
||||
state: "OH",
|
||||
zip: "43212",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Act
|
||||
actions.saveServiceLocation(context, serviceLocation);
|
||||
|
||||
// Assert
|
||||
expect(commit).toHaveBeenCalledWith(storeMutations.RESET_SCHEDULE);
|
||||
});
|
||||
|
||||
it("saveServiceLocation, should reset if appointment type is different", () => {
|
||||
// Arrange
|
||||
const context = {
|
||||
state: {
|
||||
order: {
|
||||
serviceLocation: {
|
||||
address: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
zipCode: "43212",
|
||||
state: "OH",
|
||||
zipCodeCtu: "01820",
|
||||
appointmentType: "Mobile",
|
||||
isVehicleProtected: true,
|
||||
provider: {
|
||||
providerNumber: "11111",
|
||||
address: {
|
||||
streetAddress: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
state: "OH",
|
||||
zip: "43212",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const commit = jest.fn();
|
||||
const dispatch = jest.fn();
|
||||
|
||||
context.commit = commit;
|
||||
context.dispatch = dispatch;
|
||||
|
||||
const serviceLocation = {
|
||||
address: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
zipCode: "43212",
|
||||
state: "OH",
|
||||
zipCodeCtu: "01820",
|
||||
appointmentType: "Inshop",
|
||||
isVehicleProtected: true,
|
||||
provider: {
|
||||
providerNumber: "11111",
|
||||
address: {
|
||||
streetAddress: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
state: "OH",
|
||||
zip: "43212",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Act
|
||||
actions.saveServiceLocation(context, serviceLocation);
|
||||
|
||||
// Assert
|
||||
expect(commit).toHaveBeenCalledWith(storeMutations.RESET_SCHEDULE);
|
||||
});
|
||||
|
||||
it("saveServiceLocation, should not reset if parameters are the same", () => {
|
||||
// Arrange
|
||||
const context = {
|
||||
state: {
|
||||
order: {
|
||||
serviceLocation: {
|
||||
address: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
zipCode: "43212",
|
||||
state: "OH",
|
||||
zipCodeCtu: "01820",
|
||||
appointmentType: "Mobile",
|
||||
isVehicleProtected: true,
|
||||
provider: {
|
||||
providerNumber: "11111",
|
||||
address: {
|
||||
streetAddress: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
state: "OH",
|
||||
zip: "43212",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const commit = jest.fn();
|
||||
const dispatch = jest.fn();
|
||||
|
||||
context.commit = commit;
|
||||
context.dispatch = dispatch;
|
||||
|
||||
const serviceLocation = {
|
||||
address: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
zipCode: "43212",
|
||||
state: "OH",
|
||||
zipCodeCtu: "01820",
|
||||
appointmentType: "Mobile",
|
||||
isVehicleProtected: true,
|
||||
provider: {
|
||||
providerNumber: "11111",
|
||||
address: {
|
||||
streetAddress: "123 Test Lane",
|
||||
city: "Columbus",
|
||||
state: "OH",
|
||||
zip: "43212",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Act
|
||||
actions.saveServiceLocation(context, serviceLocation);
|
||||
|
||||
// Assert
|
||||
expect(commit).not.toHaveBeenCalledWith(storeMutations.RESET_SCHEDULE);
|
||||
});
|
||||
|
||||
it("saveGlassParts, should call mutation", () => {
|
||||
// Arrange
|
||||
const context = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue