docbrown/app/javascript/crayons/Links/__tests__/Link.test.jsx
ludwiczakpawel 245e70d4a8
Crayons: Buttons vs CTAs (#15311)
* init

* buttons

* buttons, ctas, icons

* ctas fix

* links vs ctas

* alias

* fixes

* add tests for Buttons component

* add tooltip to button story controls

* add link and CTA tests

* add prop types

* docs

* designs

* docs

* focus visible moved to global place

* Updated some component snapshot tests.

* Mocked react-inlinesvg module because of https://github.com/gilbarbara/react-inlinesvg/issues/145\#issuecomment-623453339

* tests

* Copy updates

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* missed spots

* Apply suggestions from code review

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* danger accent colors

* node

* colors

* adding code comment

* better prop name: style -> variant

* button new

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Nick Taylor <nick@dev.to>
2021-11-30 20:40:32 +01:00

69 lines
1.8 KiB
JavaScript

import { h } from 'preact';
import { render } from '@testing-library/preact';
import { axe } from 'jest-axe';
import CogIcon from '@images/cog.svg';
import { Link } from '@crayons';
describe('<Link />', () => {
it('has no accessibility violations', async () => {
const { container } = render(<Link>Hello world!</Link>);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it('renders default link', () => {
const { container } = render(<Link href="/url">Hello world!</Link>);
expect(container.innerHTML).toMatchSnapshot();
});
it('renders branded link', () => {
const { container } = render(
<Link variant="branded" href="/url">
Hello world!
</Link>,
);
expect(container.innerHTML).toMatchSnapshot();
});
it('renders block link', () => {
const { container } = render(
<Link block href="/url">
Hello world!
</Link>,
);
expect(container.innerHTML).toMatchSnapshot();
});
it('renders rounded link', () => {
const { container } = render(
<Link rounded href="/url">
Hello world!
</Link>,
);
expect(container.innerHTML).toMatchSnapshot();
});
it('renders a link with icon alone', () => {
const { container } = render(<Link icon={CogIcon} href="/url" />);
expect(container.innerHTML).toMatchSnapshot();
});
it('renders with icon and text', () => {
const { container } = render(
<Link icon={CogIcon} href="/url">
Hello world!
</Link>,
);
expect(container.innerHTML).toMatchSnapshot();
});
it('renders with additional classnames', () => {
const { container } = render(
<Link className="one two three" href="/url">
Hello world!
</Link>,
);
expect(container.innerHTML).toMatchSnapshot();
});
});