-
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 2083-Added unit tests for patientStatus banner tag in commonsLib. (
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
packages/esm-commons-lib/src/components/banner-tags/.patient-status-tag.test.tsx
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,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(); | ||
}); | ||
}); |
1 change: 0 additions & 1 deletion
1
packages/esm-commons-lib/src/components/banner-tags/patient-status-tag.component.tsx
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