Skip to content

Commit

Permalink
test case added
Browse files Browse the repository at this point in the history
  • Loading branch information
semd committed Sep 29, 2021
1 parent 473fd65 commit 577f548
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions x-pack/plugins/cases/public/components/case_view/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const useGetCaseUserActionsMock = useGetCaseUserActions as jest.Mock;
const useConnectorsMock = useConnectors as jest.Mock;
const usePostPushToServiceMock = usePostPushToService as jest.Mock;
const useKibanaMock = useKibana as jest.Mocked<typeof useKibana>;
const onCaseDataSuccessMock = jest.fn();

const spacesUiApiMock = {
redirectLegacyUrl: jest.fn().mockResolvedValue(undefined),
Expand Down Expand Up @@ -127,6 +128,7 @@ export const caseProps: CaseComponentProps = {
},
fetchCase: jest.fn(),
updateCase: jest.fn(),
onCaseDataSuccess: onCaseDataSuccessMock,
};

export const caseClosedProps: CaseComponentProps = {
Expand Down Expand Up @@ -371,6 +373,15 @@ describe('CaseView ', () => {
await waitFor(() => {
expect(updateObject.updateKey).toEqual('title');
expect(updateObject.updateValue).toEqual(newTitle);
expect(updateObject.onSuccess).toBeDefined();
});

updateObject.onSuccess(); // simulate the request has succeed
await waitFor(() => {
expect(onCaseDataSuccessMock).toHaveBeenCalledWith({
...caseProps.caseData,
title: newTitle,
});
});
});

Expand Down

0 comments on commit 577f548

Please sign in to comment.