import React from 'react';
import { render } from '@testing-library/react';
import axe from '../../../../axe-helper';
import TextField from './TextField';
describe('', () => {
it('renders the component with no a11y violations', async () => {
const { container } = render();
const { getComputedStyle } = window;
// Fix warning in console
window.getComputedStyle = (elt) => getComputedStyle(elt);
const results = await axe(container.innerHTML);
expect(container.firstChild).toMatchSnapshot();
expect(results).toHaveNoViolations();
});
it('renders the component with label', () => {
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
it('renders the component and isValid set to true', () => {
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
it('renders the component with error', () => {
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
it('renders the component with size', () => {
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
it('renders the component with error and label and size', () => {
const { container } = render(
,
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders the component with prefix', () => {
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
it('throws if no name provided', () => {
console.error = jest.fn();
expect(() => render()).toThrow('Name must be set in inputProps. Check the docs.');
});
it('throws if prefix is longer than one character', () => {
console.error = jest.fn();
expect(() => render()).toThrow('Prefixes can only have one character');
});
});