Add tests for SaveSupportingItems

This commit is contained in:
Chloe Herd 2023-06-20 15:48:37 -04:00
parent 11fd5a5e67
commit f30527c64f

View file

@ -982,6 +982,81 @@ describe("Actions", () => {
expect(dispatch).toBeCalledWith(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES);
});
it("saveSupportingItems, should call mutations", () => {
// Arrange
const context = {
state: state,
};
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
// Act
actions.saveSupportingItems(context, []);
// Assert
expect(commit).toBeCalledWith(storeMutations.UPDATE_SUPPORTING_ITEMS, []);
});
it("saveSupportingItems, should call reset logic when value is new", () => {
// Arrange
const context = {
state: {
order: {
lineItems: {
supportingItems: [
"TestValue1",
"TestValue2"
],
},
},
},
};
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
// Act
actions.saveSupportingItems(context, [ "TestValue3", "TestValue4", "TestValue5" ]);
// Assert
expect(dispatch).toBeCalledWith(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES);
});
it("saveSupportingItems, should not call reset logic when value is the same", () => {
// Arrange
const context = {
state: {
order: {
lineItems: {
supportingItems: [
"TestValue1",
"TestValue2"
],
},
},
},
};
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
// Act
actions.saveSupportingItems(context, [ "TestValue1", "TestValue2" ]);
// Assert
expect(dispatch).not.toBeCalledWith(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES);
});
it("clearVin, should call mutation", () => {
// Arrange
const context = state;