Add tests for SaveSupportingItems
This commit is contained in:
parent
11fd5a5e67
commit
f30527c64f
1 changed files with 75 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue