import { render, screen, userEvent } from '../test-utils';
import TextareaWithDisplayFormat from '.';

describe('TextareaWithDisplayFormat', () => {
  const props = { displayPattern: '**-**', onChange: jest.fn() };

  it('should render input with value prop', () => {
    render(<TextareaWithDisplayFormat {...props} value="test" />);
    expect(screen.getByRole('textbox')).toHaveValue('te-st');
  });

  it('should format as you type', async () => {
    render(<TextareaWithDisplayFormat {...props} />);
    await userEvent.tab();
    await userEvent.keyboard('1234');
    expect(screen.getByRole('textbox')).toHaveValue('12-34');
  });
});
