-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(www): Create tests for mdx-link (#21103)
* fix file links * add tests for mdx-link * add test for mdx-link
- Loading branch information
1 parent
c18555c
commit 491bdf9
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react" | ||
import { render } from "@testing-library/react" | ||
import MdxLink, { shouldRenderRawLink } from "../mdx-link" | ||
|
||
jest.mock("../localized-link", () => { | ||
// Mock the component to use a different tag so we can easily differentiate | ||
return () => <span /> | ||
}) | ||
|
||
describe("mdx-link", () => { | ||
it("creates a raw link on external links", () => { | ||
const { container } = render( | ||
<MdxLink href="https://github.com/gatsbyjs.gatsby" /> | ||
) | ||
expect(container.firstChild.nodeName).toBe("A") | ||
}) | ||
|
||
it("creates a raw link on hashes", () => { | ||
const { container } = render(<MdxLink href="#gatsby" />) | ||
expect(container.firstChild.nodeName).toBe("A") | ||
}) | ||
|
||
it("creates a raw link on files", () => { | ||
const { container } = render(<MdxLink href="/gatsby-cheat-sheet.pdf" />) | ||
expect(container.firstChild.nodeName).toBe("A") | ||
}) | ||
|
||
it("creates a localized link for internal links", () => { | ||
const { container } = render(<MdxLink href="/docs" />) | ||
expect(container.firstChild.nodeName).toBe("SPAN") | ||
}) | ||
}) |