Skip to content

Commit

Permalink
test(link): ✅ add inline test snapshot for link
Browse files Browse the repository at this point in the history
  • Loading branch information
navin-moorthy committed Oct 16, 2020
1 parent e715ec3 commit e999dcd
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 57 deletions.
64 changes: 56 additions & 8 deletions src/link/__tests__/Link.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,87 @@ import { Link } from "../index";

describe("ReakitLink", () => {
it("should render correctly", () => {
const { asFragment } = render(<Link href="#">link</Link>);
const { baseElement } = render(<Link href="#">link</Link>);

expect(asFragment()).toMatchSnapshot();
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div>
<a
href="#"
>
link
</a>
</div>
</body>
`);
});

it("should render correctly with isExternal", () => {
const { asFragment } = render(
const { baseElement } = render(
<Link href="#" isExternal>
link
</Link>,
);

expect(asFragment()).toMatchSnapshot();
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div>
<a
href="#"
rel="noopener noreferrer"
target="_blank"
>
link
</a>
</div>
</body>
`);
});

it("should render correctly with isExternal & disabled", () => {
const { asFragment } = render(
const { baseElement } = render(
<Link href="#" isExternal disabled>
link
</Link>,
);

expect(asFragment()).toMatchSnapshot();
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div>
<a
aria-disabled="true"
href="#"
rel="noopener noreferrer"
style="pointer-events: none;"
tabindex="-1"
target="_blank"
>
link
</a>
</div>
</body>
`);
});

it("should render correctly with non native link tag", () => {
const { asFragment } = render(
const { baseElement } = render(
<Link as="span" onClick={() => alert("Custom Link")}>
Reakit
</Link>,
);

expect(asFragment()).toMatchSnapshot();
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div>
<span
role="link"
tabindex="0"
>
Reakit
</span>
</div>
</body>
`);
});

test("Link renders with no a11y violations", async () => {
Expand Down
49 changes: 0 additions & 49 deletions src/link/__tests__/__snapshots__/Link.test.tsx.snap

This file was deleted.

0 comments on commit e999dcd

Please sign in to comment.