diff --git a/www/src/components/__tests__/mdx-link.js b/www/src/components/__tests__/mdx-link.js new file mode 100644 index 0000000000000..8552d85a95137 --- /dev/null +++ b/www/src/components/__tests__/mdx-link.js @@ -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 () => +}) + +describe("mdx-link", () => { + it("creates a raw link on external links", () => { + const { container } = render( + + ) + expect(container.firstChild.nodeName).toBe("A") + }) + + it("creates a raw link on hashes", () => { + const { container } = render() + expect(container.firstChild.nodeName).toBe("A") + }) + + it("creates a raw link on files", () => { + const { container } = render() + expect(container.firstChild.nodeName).toBe("A") + }) + + it("creates a localized link for internal links", () => { + const { container } = render() + expect(container.firstChild.nodeName).toBe("SPAN") + }) +})