Skip to content

Commit

Permalink
OHRI-2106 Fix tests on MambaReport (#1759)
Browse files Browse the repository at this point in the history
* OHRI-2106 fixed failing tests

* cleanup

* more cleanup
  • Loading branch information
arodidev authored Jan 15, 2024
1 parent 4d1034c commit 43df089
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 41 deletions.
34 changes: 34 additions & 0 deletions packages/esm-commons-lib/src/tests/mambaReports.test.ts
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);
});
});
41 changes: 0 additions & 41 deletions packages/esm-tb-app/src/api/mambaReport.test.ts

This file was deleted.

0 comments on commit 43df089

Please sign in to comment.