-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10250 from department-of-veterans-affairs/chore/9…
…999-Usei18nInUnitTests-Home-7 chore: Updated ContactInformationScreen tests with i18n
- Loading branch information
Showing
3 changed files
with
19 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import React from 'react' | ||
|
||
import { fireEvent, screen, waitFor } from '@testing-library/react-native' | ||
import { t } from 'i18next' | ||
|
||
import { contactInformationKeys } from 'api/contactInformation/queryKeys' | ||
import { put } from 'store/api' | ||
|
@@ -51,25 +52,25 @@ describe('EditEmailScreen', () => { | |
describe('when the email is saved', () => { | ||
it('navigates back to the previous screen', async () => { | ||
fireEvent.changeText(screen.getByTestId('emailAddressEditTestID'), '[email protected]') | ||
fireEvent.press(screen.getByRole('button', { name: 'Save' })) | ||
fireEvent.press(screen.getByRole('button', { name: t('save') })) | ||
await waitFor(() => expect(onBackSpy).toHaveBeenCalled()) | ||
}) | ||
}) | ||
|
||
describe('when the email does not have an @ followed by text on save', () => { | ||
it('displays an AlertBox and field error', () => { | ||
fireEvent.changeText(screen.getByTestId('emailAddressEditTestID'), 'myemail') | ||
fireEvent.press(screen.getByRole('button', { name: 'Save' })) | ||
expect(screen.getByText('Check your email address')).toBeTruthy() | ||
expect(screen.getByText('Enter your email address again using this format: [email protected]')).toBeTruthy() | ||
fireEvent.press(screen.getByRole('button', { name: t('save') })) | ||
expect(screen.getByText(t('editEmail.alertError'))).toBeTruthy() | ||
expect(screen.getByText(t('editEmail.fieldError'))).toBeTruthy() | ||
}) | ||
}) | ||
|
||
describe('when the email input is empty on save', () => { | ||
it('displays an AlertBox and field error', () => { | ||
fireEvent.press(screen.getByRole('button', { name: 'Save' })) | ||
expect(screen.getByText('Check your email address')).toBeTruthy() | ||
expect(screen.getByText('Enter your email address again using this format: [email protected]')).toBeTruthy() | ||
fireEvent.press(screen.getByRole('button', { name: t('save') })) | ||
expect(screen.getByText(t('editEmail.alertError'))).toBeTruthy() | ||
expect(screen.getByText(t('editEmail.fieldError'))).toBeTruthy() | ||
}) | ||
}) | ||
|
||
|
@@ -94,7 +95,7 @@ describe('EditEmailScreen', () => { | |
.mockResolvedValue({}) | ||
|
||
fireEvent.changeText(screen.getByTestId('emailAddressEditTestID'), updatedEmail) | ||
fireEvent.press(screen.getByRole('button', { name: 'Save' })) | ||
fireEvent.press(screen.getByRole('button', { name: t('save') })) | ||
await waitFor(() => expect(put as jest.Mock).toBeCalledWith('/v0/user/emails', payload)) | ||
}) | ||
}) | ||
|
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