-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor LabsAndTestsDetailsScreen tests and add base64 decoding for …
…report data
- Loading branch information
Showing
4 changed files
with
67 additions
and
130 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
182 changes: 54 additions & 128 deletions
182
.../screens/HealthScreen/LabsAndTests/LabsAndTestsDetails/LabsAndTestsDetailsScreen.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 |
---|---|---|
@@ -1,128 +1,54 @@ | ||
// import React from 'react' | ||
|
||
// import { screen } from '@testing-library/react-native' | ||
|
||
// import { LabsAndTests } from 'api/types' | ||
// // import * as api from 'store/api' | ||
// import { context, mockNavProps, render, waitFor } from 'testUtils' | ||
|
||
// import LabsAndTestsDetailsScreen from './LabsAndTestsDetailsScreen' | ||
|
||
// context('LabsAndTestsDetailsScreen', () => { | ||
// const defaultLabsAndTests = { | ||
|
||
// } | ||
|
||
// const initializeTestInstance = (allergy: Allergy = defaultAllergy) => { | ||
// const props = mockNavProps(undefined, undefined, { params: { allergy: allergy } }) | ||
// render(<AllergyDetailsScreen {...props} />) | ||
// } | ||
|
||
// it('initializes correctly for default allergy', async () => { | ||
// initializeTestInstance() | ||
// await waitFor(() => expect(screen.getByText('March 12, 2019')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Type')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('medication')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Provider')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Dr. Alicia629 Ureña88 MD')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Reaction')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('None noted')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Notes')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Sulfonamides')).toBeTruthy()) | ||
// await waitFor(() => | ||
// expect( | ||
// screen.getByText( | ||
// 'We base this information on your current VA health records. If you have any questions, contact your health care team.', | ||
// ), | ||
// ).toBeTruthy(), | ||
// ) | ||
// }) | ||
|
||
// it('initializes correctly for allergy with reactions', async () => { | ||
// const allergyWithReactions = { | ||
// ...defaultAllergy, | ||
// attributes: { | ||
// ...defaultAllergy.attributes, | ||
// reactions: reactions, | ||
// }, | ||
// } | ||
|
||
// initializeTestInstance(allergyWithReactions) | ||
// await waitFor(() => expect(screen.getByText('March 12, 2019')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Type')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('medication')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Provider')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Dr. Alicia629 Ureña88 MD')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Reaction')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Urticaria (Hives)')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Notes')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Sulfonamides')).toBeTruthy()) | ||
// await waitFor(() => { | ||
// const textElement = screen.queryByText( | ||
// 'We base this information on your current VA health records. If you have any questions, contact your health care team.', | ||
// ) | ||
// expect(textElement).toBeNull() | ||
// }) | ||
// }) | ||
|
||
// it('initializes correctly for allergy with multiple categories', async () => { | ||
// const allergyWithCategories = { | ||
// ...defaultAllergy, | ||
// attributes: { | ||
// ...defaultAllergy.attributes, | ||
// reactions: reactions, | ||
// category: ['medication', 'food'], | ||
// }, | ||
// } | ||
|
||
// initializeTestInstance(allergyWithCategories) | ||
// await waitFor(() => expect(screen.getByText('March 12, 2019')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Type')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('medication')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('food')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Provider')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Dr. Alicia629 Ureña88 MD')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Reaction')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Urticaria (Hives)')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Notes')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Sulfonamides')).toBeTruthy()) | ||
// await waitFor(() => { | ||
// const textElement = screen.queryByText( | ||
// 'We base this information on your current VA health records. If you have any questions, contact your health care team.', | ||
// ) | ||
// expect(textElement).toBeNull() | ||
// }) | ||
// }) | ||
|
||
// it('initializes correctly for allergy with multiple notes', async () => { | ||
// const allergyWithNotes = { | ||
// ...defaultAllergy, | ||
// attributes: { | ||
// ...defaultAllergy.attributes, | ||
// reactions: reactions, | ||
// category: ['medication', 'food'], | ||
// notes: notes, | ||
// }, | ||
// } | ||
|
||
// initializeTestInstance(allergyWithNotes) | ||
// await waitFor(() => expect(screen.getByText('March 12, 2019')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Type')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('medication')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('food')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Provider')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Dr. Alicia629 Ureña88 MD')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Reaction')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Urticaria (Hives)')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Notes')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Sulfonamides')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Patient has a family history of sulfa allergy')).toBeTruthy()) | ||
// await waitFor(() => expect(screen.getByText('Additional episode of hives')).toBeTruthy()) | ||
// await waitFor(() => { | ||
// const textElement = screen.queryByText( | ||
// 'We base this information on your current VA health records. If you have any questions, contact your health care team.', | ||
// ) | ||
// expect(textElement).toBeNull() | ||
// }) | ||
// }) | ||
// }) | ||
import React from 'react' | ||
|
||
import { screen } from '@testing-library/react-native' | ||
|
||
import { LabsAndTests } from 'api/types' | ||
// import * as api from 'store/api' | ||
import { context, mockNavProps, render, waitFor } from 'testUtils' | ||
|
||
import LabsAndTestsDetailsScreen from './LabsAndTestsDetailsScreen' | ||
|
||
context('LabsAndTestsDetailsScreen', () => { | ||
const defaultLabsAndTests = { | ||
id: 'I2-2BCP5BAI6N7NQSAPSVIJ6INQ4A000000', | ||
type: 'diagnostic_report', | ||
attributes: { | ||
display: 'Surgical Pathology', | ||
testCode: 'SP', | ||
dateCompleted: '{{now - 1 month}}', | ||
encodedData: | ||
'RGF0ZSBTcGVjIHRha2VuOiBOb3YgMDEsIDIwMTggMTU6NDkgIFBhdGhvbG9naXN0Ok1VUlRVWkEgTE9LSEFORFdBTEFEYXRlIFNwZWMgcmVjJ2Q6IE5vdiAwMSwgMjAxOCAxNTo1MSAgUmVzaWRlbnQ6IERhdGUgIGNvbXBsZXRlZDogTm92IDAxLCAyMDE4ICAgICAgICBBY2Nlc3Npb24gIzogU1AgMTggNVN1Ym1pdHRlZCBieTogS0FMQUhBU1RJLCBWRU5LQVRBIFMgICBQcmFjdGl0aW9uZXI6UEFETUEgQk9ERFVMVVJJLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLVNwZWNpbWVuOiBCT05FIE1BUlJPVz0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLT0tLVBlcmZvcm1pbmcgTGFib3JhdG9yeTpTdXJnaWNhbCBQYXRob2xvZ3kgUmVwb3J0IFBlcmZvcm1lZCBCeTogQ0hZU0hSIFRFU1QgTEFCMjM2MCBFIFBFUlNISU5HIEJMVkQgQ0hFWUVOTkUsIEZMIDgyMDAxLTUzNTZudWxs', | ||
sampleSite: 'TESTING BONE MARROW', | ||
location: 'VA TEST LAB', | ||
}, | ||
} | ||
|
||
const initializeTestInstance = (labAndTest: LabsAndTests = defaultLabsAndTests) => { | ||
const props = mockNavProps(undefined, undefined, { params: { labOrTest: labAndTest } }) | ||
return render(<LabsAndTestsDetailsScreen {...props} />) | ||
} | ||
|
||
it('base64 decodes the encodedData -- report data', async () => { | ||
const dataWithAtob = { | ||
...defaultLabsAndTests, | ||
} | ||
const { getByTestId } = initializeTestInstance({ ...dataWithAtob }) | ||
await waitFor(() => | ||
expect(getByTestId('decoded-report').children[0]).toEqual( | ||
`Date Spec taken: Nov 01, 2018 15:49 Pathologist:MURTUZA LOKHANDWALADate Spec rec'd: Nov 01, 2018 15:51 Resident: Date completed: Nov 01, 2018 Accession #: SP 18 5Submitted by: KALAHASTI, VENKATA S Practitioner:PADMA BODDULURI-------------------------------------------------------------------------------Specimen: BONE MARROW=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--Performing Laboratory:Surgical Pathology Report Performed By: CHYSHR TEST LAB2360 E PERSHING BLVD CHEYENNE, FL 82001-5356null`, | ||
), | ||
) | ||
}) | ||
|
||
it('renders the placeholder for encodedData if no encodedData is present', async () => { | ||
const sampleData = { | ||
...defaultLabsAndTests, | ||
attributes: { | ||
...defaultLabsAndTests.attributes, | ||
encodedData: undefined, | ||
}, | ||
} | ||
const { getByTestId } = initializeTestInstance({ ...sampleData }) | ||
await waitFor(() => expect(getByTestId('decoded-report').children[0]).toEqual('None noted')) | ||
}) | ||
}) |
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
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