UNPKG

@navinc/base-react-components

Version:
15 lines (13 loc) 677 B
import { render, screen, fireEvent } from '@testing-library/react' import { PasswordInput as RawPasswordInport } from './password-input.js' import { withAppContext } from './tests/with-app-context.js' const PasswordInput = withAppContext(RawPasswordInport) describe('<PasswordInput />', () => { it('changes isPasswordShown from false to true', () => { render(<PasswordInput name="password" label="password" />) fireEvent.change(screen.getByLabelText(/password/i), { target: { value: 'pa$$w0rd' } }) expect(() => screen.getByText(/hide/i)).toThrow() fireEvent.click(screen.getByText(/show/i)) expect(() => screen.getByText(/hide/i)).not.toThrow() }) })