-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OHRI-2106 Fix tests on MambaReport (#1759)
* OHRI-2106 fixed failing tests * cleanup * more cleanup
- Loading branch information
Showing
2 changed files
with
34 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { fetchMambaReportData } from '../api/api'; | ||
import { openmrsFetch } from '@openmrs/esm-framework'; | ||
import '@testing-library/jest-dom'; | ||
|
||
jest.mock('@openmrs/esm-framework'); | ||
|
||
describe('fetchMambaReportData', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test('fetches report data successfully and parses result', async () => { | ||
const reportId = 'test-report-id'; | ||
|
||
const mockResponse: any = { | ||
data: { | ||
results: [ | ||
{ | ||
record: [{ value: '0' }], | ||
}, | ||
], | ||
}, | ||
json: jest.fn().mockResolvedValue({}), | ||
}; | ||
|
||
(openmrsFetch as jest.Mock).mockResolvedValueOnce(mockResponse); | ||
|
||
const result = await fetchMambaReportData(reportId); | ||
|
||
expect(openmrsFetch).toHaveBeenCalledWith(`ws/rest/v1/mamba/report?report_id=${reportId}`); | ||
expect(mockResponse.json).toHaveBeenCalled(); | ||
expect(result).toEqual(0); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.