UNPKG

@navinc/base-react-components

Version:
16 lines (14 loc) 704 B
import React from 'react' 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() }) })