import React from 'react';
import { fireEvent, render } from '@testing-library/react';
import { axe } from 'jest-axe';
import 'jest-styled-components';
import 'jest-axe/extend-expect';
import 'regenerator-runtime/runtime';
import { Grommet } from '../../Grommet';
import { Text } from '..';
test('should have no accessibility violations', async () => {
const { container } = render(
Example
,
);
const results = await axe(container);
expect(results).toHaveNoViolations();
expect(container.firstChild).toMatchSnapshot();
});
test('renders', () => {
const { container } = render(
text
,
);
expect(container.firstChild).toMatchSnapshot();
});
test('accepts ref', () => {
const ref = React.createRef();
const { container } = render(
text
,
);
expect(ref.current).not.toBeNull();
expect(container.firstChild).toMatchSnapshot();
});
test('renders size', () => {
const { container } = render(
,
);
expect(container.firstChild).toMatchSnapshot();
});
test('renders textAlign', () => {
const { container } = render(
,
);
expect(container.firstChild).toMatchSnapshot();
});
test('renders margin', () => {
const { container } = render(
,
);
expect(container.firstChild).toMatchSnapshot();
});
const LONG = 'a b c d e f g h i j k l m n o p q r s t u v w x y z';
test('renders truncate', () => {
const { container } = render(
{LONG}
{LONG}
,
);
expect(container.firstChild).toMatchSnapshot();
});
test('renders color', () => {
const { container } = render(
,
);
expect(container.firstChild).toMatchSnapshot();
});
test('renders tag', () => {
const { container } = render(
,
);
expect(container.firstChild).toMatchSnapshot();
});
test('proxies tag', () => {
const { container: tagComponent } = render(
,
);
const { container: asComponent } = render(
,
);
expect(tagComponent).toEqual(asComponent);
});
test('renders weight', () => {
const { container } = render(
,
);
expect(container.firstChild).toMatchSnapshot();
});
test('renders tip', () => {
const { container, getByText } = render(
Default Tip
,
);
fireEvent.mouseOver(getByText('Default Tip'));
expect(container.firstChild).toMatchSnapshot();
});
test('should apply a11yTitle or aria-label', () => {
const { container, getByLabelText } = render(
Example
Example
,
);
expect(getByLabelText('test')).toBeTruthy();
expect(getByLabelText('test-2')).toBeTruthy();
expect(container.firstChild).toMatchSnapshot();
});