Skip to content

Commit

Permalink
using navigate as mock
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush-AI committed Jul 13, 2023
1 parent e1d61da commit 2029a01
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { navigate } from '@openmrs/esm-framework';

describe('EditPatientDetailsButton', () => {
it('should navigate to the edit page when clicked', () => {
const mockNavigate = navigate as jest.Mock;
jest.mock('@openmrs/esm-framework', () => {
const originalModule = jest.requireActual('@openmrs/esm-framework');
return {
Expand All @@ -18,7 +19,7 @@ describe('EditPatientDetailsButton', () => {
const button = screen.getByRole('menuitem');
fireEvent.click(button);

expect(navigate).toHaveBeenCalledWith({ to: expect.stringContaining(`/patient/${patientUuid}/edit`) });
expect(mockNavigate).toHaveBeenCalledWith({ to: expect.stringContaining(`/patient/${patientUuid}/edit`) });
});

it('should call the onTransition function when provided', () => {
Expand Down

0 comments on commit 2029a01

Please sign in to comment.