Skip to content

Commit

Permalink
Ohri 2083-Added unit tests for patientStatus banner tag in commonsLib. (
Browse files Browse the repository at this point in the history
  • Loading branch information
kirwea authored Jan 17, 2024
1 parent 1567f26 commit f8b6790
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { render, act, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import { PatientStatusBannerTag } from './patient-status-tag.component';
import { isPatientHivPositive } from './patientHivStatus';

const mockIsPatientHivPositive = isPatientHivPositive as jest.Mock;
jest.mock('./patientHivStatus');

describe('PatientStatusBannerTag', () => {
beforeEach(() => {
jest.clearAllMocks();
});

const hivPositiveSampleUuid = '703AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';

describe('PatientStatusBannerTag', () => {
it('renders red tag when patient is HIV positive', async () => {
mockIsPatientHivPositive.mockResolvedValue(true);
await act(async () => {
render(<PatientStatusBannerTag patientUuid={hivPositiveSampleUuid} />);
});

expect(screen.getByText(/HIV Positive/i)).toBeInTheDocument();
});
});

it('does not render red tag when patient is not HIV positive', async () => {
await act(async () => {
(isPatientHivPositive as jest.Mock).mockResolvedValue(false);
render(<PatientStatusBannerTag patientUuid="sampleUuid" />);
});

expect(screen.queryByText('HIV Positive')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useEffect, useState } from 'react';
import { Tag } from '@carbon/react';
import { useTranslation } from 'react-i18next';
import styles from './active-visit-tag.scss';
import { isPatientHivPositive } from './patientHivStatus';

export function PatientStatusBannerTag({ patientUuid }) {
Expand Down

0 comments on commit f8b6790

Please sign in to comment.