From 56e645f4ba4f0ad83858687548577f859878aa5a Mon Sep 17 00:00:00 2001 From: Caleb Cox Date: Tue, 5 Nov 2024 13:28:50 -0600 Subject: [PATCH] Add tests --- .../AddAddressModal/AddAddressModal.test.tsx | 22 ++++++++++ .../EditContactAddressModal.test.tsx | 41 +++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/AddAddressModal/AddAddressModal.test.tsx b/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/AddAddressModal/AddAddressModal.test.tsx index f5ecb6267..71f7ee82d 100644 --- a/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/AddAddressModal/AddAddressModal.test.tsx +++ b/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/AddAddressModal/AddAddressModal.test.tsx @@ -90,6 +90,28 @@ describe('AddAddressModal', () => { expect(handleClose).toHaveBeenCalled(); }); + it('requires at least one field to be filled', async () => { + const { getByRole } = render( + + + + + + + , + ); + + const saveButton = getByRole('button', { name: 'Save' }); + await waitFor(() => expect(saveButton).toBeDisabled()); + + userEvent.type(getByRole('textbox', { name: 'City' }), 'City'); + await waitFor(() => expect(saveButton).not.toBeDisabled()); + }); + it('should create contact address', async () => { const mutationSpy = jest.fn(); const newStreet = '4321 Neat Street'; diff --git a/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/EditContactAddressModal/EditContactAddressModal.test.tsx b/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/EditContactAddressModal/EditContactAddressModal.test.tsx index 0bcaf3c43..bad110dae 100644 --- a/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/EditContactAddressModal/EditContactAddressModal.test.tsx +++ b/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/EditContactAddressModal/EditContactAddressModal.test.tsx @@ -115,6 +115,47 @@ describe('EditContactAddressModal', () => { expect(handleClose).toHaveBeenCalled(); }); + it('requires at least one field to be filled', async () => { + const { getByRole } = render( + + + + + + + , + ); + + const saveButton = getByRole('button', { name: 'Save' }); + await waitFor(() => expect(saveButton).not.toBeDisabled()); + + userEvent.clear(getByRole('combobox', { name: 'Street' })); + await waitFor(() => expect(saveButton).toBeDisabled()); + + userEvent.type(getByRole('textbox', { name: 'City' }), 'City'); + await waitFor(() => expect(saveButton).not.toBeDisabled()); + }); + it('should edit contact address', async () => { const mutationSpy = jest.fn(); const newStreet = '4321 Neat Street';