-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ForwardRef support for PasswordField, FieldGroup, & FieldGroupIconBut…
…ton (#832) * ForwardRef support for PasswordField * ForwardRef for FieldGroup * ForwardRef FieldGroupIconButton
- Loading branch information
Showing
7 changed files
with
200 additions
and
46 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@aws-amplify/ui-react": patch | ||
--- | ||
|
||
ForwardRef support for PasswordField, FieldGroup, & FieldGroupIconButton primitives. |
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
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
32 changes: 32 additions & 0 deletions
32
packages/react/src/primitives/FieldGroupIcon/__tests__/FieldGroupIconButton.test.tsx
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import { ComponentClassNames } from '../../shared'; | ||
import { FieldGroupIconButton } from '../FieldGroupIconButton'; | ||
|
||
describe('FieldGroupIconButton component', () => { | ||
const testId = 'fieldGroupTestId'; | ||
it('should render default and custom classname for FieldGroupIconButton', async () => { | ||
render(<FieldGroupIconButton className="custom-class" testId={testId} />); | ||
|
||
const fieldGroup = await screen.findByTestId(testId); | ||
|
||
expect(fieldGroup).toHaveClass('custom-class'); | ||
expect(fieldGroup).toHaveClass(ComponentClassNames.FieldGroupIconButton); | ||
}); | ||
|
||
it('should forward ref to DOM element', async () => { | ||
const ref = React.createRef<HTMLButtonElement>(); | ||
render( | ||
<FieldGroupIconButton | ||
className="custom-class" | ||
ref={ref} | ||
testId={testId} | ||
/> | ||
); | ||
|
||
await screen.findByRole('button'); | ||
|
||
expect(ref.current.nodeName).toBe('BUTTON'); | ||
}); | ||
}); |
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