diff --git a/src/components/Tool/FixPhoneNumbers/Contact.test.tsx b/src/components/Tool/FixPhoneNumbers/Contact.test.tsx index f63fef861..a5e1c2896 100644 --- a/src/components/Tool/FixPhoneNumbers/Contact.test.tsx +++ b/src/components/Tool/FixPhoneNumbers/Contact.test.tsx @@ -35,6 +35,7 @@ describe('FixPhoneNumbers-Contact', () => { const handleDeleteModalOpenMock = jest.fn(); const handleAddMock = jest.fn(); const handleChangePrimaryMock = jest.fn(); + const updatePhoneNumber = jest.fn(); const { getByText, getByTestId, getByDisplayValue } = render( @@ -50,6 +51,7 @@ describe('FixPhoneNumbers-Contact', () => { handleAdd={handleAddMock} handleChangePrimary={handleChangePrimaryMock} setContactFocus={setContactFocus} + handleUpdate={updatePhoneNumber} /> , @@ -67,6 +69,7 @@ describe('FixPhoneNumbers-Contact', () => { const handleDeleteModalOpenMock = jest.fn(); const handleAddMock = jest.fn(); const handleChangePrimaryMock = jest.fn(); + const updatePhoneNumber = jest.fn(); const { getByTestId } = render( @@ -82,6 +85,7 @@ describe('FixPhoneNumbers-Contact', () => { handleAdd={handleAddMock} handleChangePrimary={handleChangePrimaryMock} setContactFocus={setContactFocus} + handleUpdate={updatePhoneNumber} /> , @@ -103,6 +107,7 @@ describe('FixPhoneNumbers-Contact', () => { const handleDeleteModalOpenMock = jest.fn(); const handleAddMock = jest.fn(); const handleChangePrimaryMock = jest.fn(); + const updatePhoneNumber = jest.fn(); const { getByTestId } = render( @@ -118,6 +123,7 @@ describe('FixPhoneNumbers-Contact', () => { handleAdd={handleAddMock} handleChangePrimary={handleChangePrimaryMock} setContactFocus={setContactFocus} + handleUpdate={updatePhoneNumber} /> , @@ -131,5 +137,7 @@ describe('FixPhoneNumbers-Contact', () => { expect(handleChangePrimaryMock).toHaveBeenCalled(); userEvent.click(getByTestId('delete-testid-1')); expect(handleDeleteModalOpenMock).toHaveBeenCalled(); + userEvent.click(getByTestId(`confirmButton-${testData.id}`)); + expect(updatePhoneNumber).toHaveBeenCalled(); }); }); diff --git a/src/components/Tool/FixPhoneNumbers/Contact.tsx b/src/components/Tool/FixPhoneNumbers/Contact.tsx index 425f0ba55..f2b6f7582 100644 --- a/src/components/Tool/FixPhoneNumbers/Contact.tsx +++ b/src/components/Tool/FixPhoneNumbers/Contact.tsx @@ -114,6 +114,11 @@ interface Props { handleAdd: (personId: string, number: string) => void; handleChangePrimary: (personId: string, numberIndex: number) => void; setContactFocus: SetContactFocus; + handleUpdate: ( + personId: string, + name: string, + numbers: PhoneNumberData[], + ) => void; } const Contact: React.FC = ({ @@ -127,6 +132,7 @@ const Contact: React.FC = ({ // Remove below line when function is being used. // eslint-disable-next-line @typescript-eslint/no-unused-vars setContactFocus, + handleUpdate, }) => { const { t } = useTranslation(); const locale = useLocale(); @@ -349,7 +355,12 @@ const Contact: React.FC = ({ style={{ paddingLeft: theme.spacing(1) }} > -