Skip to content

Commit

Permalink
chore/9994-Usei18nInUnitTests-Home-2 (#10140)
Browse files Browse the repository at this point in the history
  • Loading branch information
oddballdave authored Nov 12, 2024
1 parent 4b2350a commit c84de4a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react'

import { screen } from '@testing-library/react-native'
import { t } from 'i18next'

import { context, mockNavProps, render } from 'testUtils'
import { displayedTextPhoneNumber } from 'utils/formattingUtils'

import ContactVAScreen from './ContactVAScreen'

Expand All @@ -18,14 +20,10 @@ context('ContactVAScreen', () => {
})

it('initializes correctly', () => {
expect(screen.getByRole('link', { name: 'Talk to the Veterans Crisis Line now' })).toBeTruthy()
expect(screen.getByRole('header', { name: 'Call MyVA411' })).toBeTruthy()
expect(
screen.getByText(
'MyVA411 is our main VA information line. We can help connect you to any of our VA contact centers.',
),
).toBeTruthy()
expect(screen.getByRole('link', { name: '800-698-2411' })).toBeTruthy()
expect(screen.getByRole('link', { name: 'TTY: 711' })).toBeTruthy()
expect(screen.getByRole('link', { name: t('crisisLineButton.label') })).toBeTruthy()
expect(screen.getByRole('header', { name: t('contactVA.va411.callMy') })).toBeTruthy()
expect(screen.getByText(t('contactVA.va411.body'))).toBeTruthy()
expect(screen.getByRole('link', { name: displayedTextPhoneNumber(t('8006982411')) })).toBeTruthy()
expect(screen.getByRole('link', { name: t('contactVA.tty.displayText') })).toBeTruthy()
})
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'

import { screen } from '@testing-library/react-native'
import { t } from 'i18next'

import { personalInformationKeys } from 'api/personalInformation/queryKeys'
import { BranchesOfServiceConstants, MilitaryServiceHistoryData, ServiceHistoryAttributes } from 'api/types'
Expand Down Expand Up @@ -75,10 +76,10 @@ context('ProfileScreen', () => {
.calledWith('/v0/military-service-history')
.mockResolvedValue(militaryServiceHistoryData)
initializeTestInstance()
await waitFor(() => expect(screen.queryByText('Personal information')).toBeFalsy())
await waitFor(() => expect(screen.queryByText('Contact information')).toBeFalsy())
await waitFor(() => expect(screen.getByText('Military information')).toBeTruthy())
await waitFor(() => expect(screen.getByText('Settings')).toBeTruthy())
await waitFor(() => expect(screen.queryByText(t('personalInformation.title'))).toBeFalsy())
await waitFor(() => expect(screen.queryByText(t('contactInformation.title'))).toBeFalsy())
await waitFor(() => expect(screen.getByText(t('militaryInformation.title'))).toBeTruthy())
await waitFor(() => expect(screen.getByText(t('settings.title'))).toBeTruthy())
})
})

Expand All @@ -89,9 +90,7 @@ context('ProfileScreen', () => {
.mockRejectedValue({ networkError: true } as api.APIError)
initializeTestInstance()

await waitFor(() =>
expect(screen.getByText('We can’t show all your information right now. Check back later.')).toBeTruthy(),
)
await waitFor(() => expect(screen.getByText(t('aboutYou.error.cantShowAllInfo'))).toBeTruthy())
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import { Alert } from 'react-native'

import { fireEvent, screen } from '@testing-library/react-native'
import { t } from 'i18next'

import { context, render } from 'testUtils'

Expand All @@ -13,23 +14,19 @@ context('VeteransCrisisLineScreen', () => {
})

it('initializes correctly', () => {
expect(screen.getByRole('header', { name: 'We’re here anytime, day or night – 24/7' })).toBeTruthy()
expect(
screen.getByText(
"If you're a Veteran in crisis or concerned about one, connect with our caring, qualified responders for confidential help. Many of them are Veterans themselves.",
),
).toBeTruthy()
expect(screen.getByRole('link', { name: 'Call 988 and select 1' })).toBeTruthy()
expect(screen.getByRole('link', { name: 'Text 838255' })).toBeTruthy()
expect(screen.getByRole('link', { name: 'Start a confidential chat' })).toBeTruthy()
expect(screen.getByRole('link', { name: 'TTY: 800-799-4889' })).toBeTruthy()
expect(screen.getByRole('header', { name: 'Get more resources' })).toBeTruthy()
expect(screen.getByRole('link', { name: 'VeteransCrisisLine.net' })).toBeTruthy()
expect(screen.getByRole('header', { name: t('veteransCrisisLine.weAreHereForYou') })).toBeTruthy()
expect(screen.getByText(t('veteransCrisisLine.connectWithResponders'))).toBeTruthy()
expect(screen.getByRole('link', { name: t('veteransCrisisLine.crisisCallNumberDisplayed') })).toBeTruthy()
expect(screen.getByRole('link', { name: t('veteransCrisisLine.textNumberDisplayed') })).toBeTruthy()
expect(screen.getByRole('link', { name: t('veteransCrisisLine.startConfidentialChat') })).toBeTruthy()
expect(screen.getByRole('link', { name: t('veteransCrisisLine.hearingLossNumberDisplayed') })).toBeTruthy()
expect(screen.getByRole('header', { name: t('veteransCrisisLine.getMoreResources') })).toBeTruthy()
expect(screen.getByRole('link', { name: t('veteransCrisisLine.urlDisplayed') })).toBeTruthy()
})

describe('when the veteransCrisisLine.net link is clicked', () => {
it('should show alert', () => {
fireEvent.press(screen.getByRole('link', { name: 'VeteransCrisisLine.net' }))
fireEvent.press(screen.getByRole('link', { name: t('veteransCrisisLine.urlDisplayed') }))
expect(Alert.alert).toBeCalled()
})
})
Expand Down

0 comments on commit c84de4a

Please sign in to comment.