Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed Jun 16, 2021
1 parent 412082a commit c2fcd4b
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ jest.mock('../../../../utils/kibana_react');

describe('Create case', () => {
const mockCreateCase = jest.fn();
const mockNavigateToApp = jest.fn();
const mockNavigateToUrl = jest.fn();
const mockCasesUrl = 'https://elastic.co/app/observability/cases';
beforeEach(() => {
jest.resetAllMocks();
(useKibana as jest.Mock).mockReturnValue({
services: {
cases: {
getCreateCase: mockCreateCase,
},
application: { navigateToApp: mockNavigateToApp },
application: { navigateToUrl: mockNavigateToUrl, getUrlForApp: () => mockCasesUrl },
},
});
});
Expand All @@ -52,7 +53,7 @@ describe('Create case', () => {
onCancel();
},
},
application: { navigateToApp: mockNavigateToApp },
application: { navigateToUrl: mockNavigateToUrl, getUrlForApp: () => mockCasesUrl },
},
});
mount(
Expand All @@ -61,7 +62,7 @@ describe('Create case', () => {
</EuiThemeProvider>
);

await waitFor(() => expect(mockNavigateToApp).toHaveBeenCalledWith(`${CASES_APP_ID}`));
await waitFor(() => expect(mockNavigateToUrl).toHaveBeenCalledWith(`${mockCasesUrl}`));
});

it('should redirect to new case when posting the case', async () => {
Expand All @@ -72,7 +73,7 @@ describe('Create case', () => {
onSuccess(basicCase);
},
},
application: { navigateToApp: mockNavigateToApp },
application: { navigateToUrl: mockNavigateToUrl, getUrlForApp: () => mockCasesUrl },
},
});
mount(
Expand All @@ -82,9 +83,10 @@ describe('Create case', () => {
);

await waitFor(() =>
expect(mockNavigateToApp).toHaveBeenNthCalledWith(1, `${CASES_APP_ID}`, {
path: getCaseDetailsUrl({ id: basicCase.id }),
})
expect(mockNavigateToUrl).toHaveBeenNthCalledWith(
1,
`${mockCasesUrl}${getCaseDetailsUrl({ id: basicCase.id })}`
)
);
});
});

0 comments on commit c2fcd4b

Please sign in to comment.