|
|
|
|
@ -8,15 +8,15 @@ describe('PasswordField', () => { |
|
|
|
|
placeholder: 'enter password', |
|
|
|
|
'data-testid': 'password-field', |
|
|
|
|
}; |
|
|
|
|
it('should renders correctly', () => { |
|
|
|
|
it('should render correctly', () => { |
|
|
|
|
render(<PasswordField {...props} />); |
|
|
|
|
expect(screen.getByTestId('password-field')).toBeInTheDocument(); |
|
|
|
|
expect(screen.getByRole('button')).toBeInTheDocument(); |
|
|
|
|
expect(screen.getByRole('switch', { name: 'Show password' })).toBeInTheDocument(); |
|
|
|
|
}); |
|
|
|
|
it('should able to show password value if clicked on password-reveal icon', () => { |
|
|
|
|
render(<PasswordField {...props} />); |
|
|
|
|
expect(screen.getByTestId('password-field')).toHaveProperty('type', 'password'); |
|
|
|
|
fireEvent.click(screen.getByRole('button')); |
|
|
|
|
fireEvent.click(screen.getByRole('switch', { name: 'Show password' })); |
|
|
|
|
expect(screen.getByTestId('password-field')).toHaveProperty('type', 'text'); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|