-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f35e90
commit 6fa4abd
Showing
3 changed files
with
21 additions
and
13 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,12 +1,13 @@ | ||
import { screen } from '@folio/jest-config-stripes/testing-library/react'; | ||
import userEvent from '@folio/jest-config-stripes/testing-library/user-event'; | ||
import { Form } from 'react-final-form'; | ||
|
||
import '__mock__/stripesComponents.mock'; | ||
import { screen } from '@folio/jest-config-stripes/testing-library/react'; | ||
import userEvent from '@folio/jest-config-stripes/testing-library/user-event'; | ||
|
||
import renderWithRouter from 'helpers/renderWithRouter'; | ||
import EditContactInfo from './EditContactInfo'; | ||
|
||
jest.unmock('@folio/stripes/components'); | ||
|
||
const onSubmit = jest.fn(); | ||
|
||
const arrayMutators = { | ||
|
@@ -28,7 +29,8 @@ const renderEditContactInfo = (props) => { | |
<EditContactInfo {...props} /> | ||
</> | ||
); | ||
renderWithRouter( | ||
|
||
return renderWithRouter( | ||
<Form | ||
id="form-user" | ||
mutators={{ | ||
|
@@ -71,15 +73,21 @@ describe('Render Edit contact Information component', () => { | |
renderEditContactInfo(props); | ||
expect(screen.getByText('AddressEditList')).toBeInTheDocument(); | ||
}); | ||
|
||
it('Must be rendered', async () => { | ||
renderEditContactInfo(props); | ||
await userEvent.type(document.querySelector('[id="adduser_email"]'), '[email protected]'); | ||
expect(document.querySelector('[id="adduser_email"]').value).toBe('[email protected]'); | ||
|
||
const emailInput = screen.getByRole('textbox', { name: /email/i }); | ||
|
||
await userEvent.type(emailInput, '[email protected]'); | ||
expect(emailInput.value).toBe('[email protected]'); | ||
}); | ||
|
||
it('should render with disabled fields', () => { | ||
renderEditContactInfo({ ...props, disabled: true }); | ||
expect(document.querySelector('[id="adduser_email"]')).toBeDisabled(); | ||
expect(document.querySelector('[id="adduser_phone"]')).toBeDisabled(); | ||
expect(document.querySelector('[id="adduser_mobilePhone"]')).toBeDisabled(); | ||
|
||
expect(screen.getByRole('textbox', { name: /email/i })).toBeDisabled(); | ||
expect(screen.getByRole('textbox', { name: /mobilePhone/i })).toBeDisabled(); | ||
expect(screen.getByLabelText('ui-users.contact.phone')).toBeDisabled(); | ||
}); | ||
}); |
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