Skip to content

Commit

Permalink
fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hadijahkyampeire committed Sep 23, 2024
1 parent e26216a commit 1af94bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const EncounterList: React.FC<EncounterListProps> = ({
(encounters: OpenmrsEncounter[]) => {
const rows = encounters.map((encounter) => {
const tableRow: { id: string; actions: any } = { id: encounter.uuid, actions: null };
// inject launch actions

encounter['launchFormActions'] = {
editEncounter: () =>
launchEncounterForm(
Expand All @@ -205,7 +205,7 @@ export const EncounterList: React.FC<EncounterListProps> = ({
patientUuid,
),
};
// process columns

columns.forEach((column) => {
let val = column?.getValue(encounter);
if (column.link) {
Expand All @@ -225,7 +225,7 @@ export const EncounterList: React.FC<EncounterListProps> = ({
}
tableRow[column.key] = val;
});
// If custom config is available, generate actions accordingly; otherwise, fallback to the default actions.

const actions = tableRow.actions?.length ? tableRow.actions : defaultActions;
tableRow['actions'] = (
<OverflowMenu flipped className={styles.flippedOverflowMenu} data-testid="actions-id">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('EncounterList', () => {
test('renders an loading state if data is loading', () => {
jest
.spyOn(encounterRowsHook, 'useEncounterRows')
.mockReturnValue({ encounters: [], isLoading: true, error: null, onFormSave: () => {} });
.mockReturnValue({ encounters: [], total: 0, isLoading: true, error: null, onFormSave: () => {} });

jest.spyOn(formsJsonHook, 'useFormsJson').mockReturnValue({ formsJson: [], isLoading: true });

Expand All @@ -75,7 +75,7 @@ describe('EncounterList', () => {
test('renders an empty state if data is null', () => {
jest
.spyOn(encounterRowsHook, 'useEncounterRows')
.mockReturnValue({ encounters: [], isLoading: false, error: null, onFormSave: () => {} });
.mockReturnValue({ encounters: [], total: 0, isLoading: false, error: null, onFormSave: () => {} });

jest.spyOn(formsJsonHook, 'useFormsJson').mockReturnValue({ formsJson: [], isLoading: false });

Expand All @@ -90,6 +90,7 @@ describe('EncounterList', () => {
test('should render the encounter list component', () => {
jest.spyOn(encounterRowsHook, 'useEncounterRows').mockReturnValue({
encounters: mockEncounter,
total: 1,
isLoading: false,
error: null,
onFormSave: () => {},
Expand Down

0 comments on commit 1af94bf

Please sign in to comment.