From c84de4aee642ca2dc1b71426ea4e927e8a92d3c0 Mon Sep 17 00:00:00 2001 From: Dave Formanek <184258725+oddballdave@users.noreply.github.com> Date: Tue, 12 Nov 2024 10:01:46 -0700 Subject: [PATCH] chore/9994-Usei18nInUnitTests-Home-2 (#10140) --- .../ContactVAScreen/ContactVAScreen.test.tsx | 16 ++++++------- .../ProfileScreen/ProfileScreen.test.tsx | 13 +++++------ .../VeteransCrisisLineScreen.test.tsx | 23 ++++++++----------- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/VAMobile/src/screens/HomeScreen/ContactVAScreen/ContactVAScreen.test.tsx b/VAMobile/src/screens/HomeScreen/ContactVAScreen/ContactVAScreen.test.tsx index 71eab71b885..101314e4ffc 100644 --- a/VAMobile/src/screens/HomeScreen/ContactVAScreen/ContactVAScreen.test.tsx +++ b/VAMobile/src/screens/HomeScreen/ContactVAScreen/ContactVAScreen.test.tsx @@ -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' @@ -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() }) }) diff --git a/VAMobile/src/screens/HomeScreen/ProfileScreen/ProfileScreen.test.tsx b/VAMobile/src/screens/HomeScreen/ProfileScreen/ProfileScreen.test.tsx index eb0885e90a3..06e637921d1 100644 --- a/VAMobile/src/screens/HomeScreen/ProfileScreen/ProfileScreen.test.tsx +++ b/VAMobile/src/screens/HomeScreen/ProfileScreen/ProfileScreen.test.tsx @@ -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' @@ -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()) }) }) @@ -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()) }) }) }) diff --git a/VAMobile/src/screens/HomeScreen/VeteransCrisisLineScreen/VeteransCrisisLineScreen.test.tsx b/VAMobile/src/screens/HomeScreen/VeteransCrisisLineScreen/VeteransCrisisLineScreen.test.tsx index b8a8c907e3d..8d6a4e2c48d 100644 --- a/VAMobile/src/screens/HomeScreen/VeteransCrisisLineScreen/VeteransCrisisLineScreen.test.tsx +++ b/VAMobile/src/screens/HomeScreen/VeteransCrisisLineScreen/VeteransCrisisLineScreen.test.tsx @@ -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' @@ -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() }) })