File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
www/src/components/__tests__ Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React from "react"
2
+ import { render } from "@testing-library/react"
3
+ import MdxLink , { shouldRenderRawLink } from "../mdx-link"
4
+
5
+ jest . mock ( "../localized-link" , ( ) => {
6
+ // Mock the component to use a different tag so we can easily differentiate
7
+ return ( ) => < span />
8
+ } )
9
+
10
+ describe ( "mdx-link" , ( ) => {
11
+ it ( "creates a raw link on external links" , ( ) => {
12
+ const { container } = render (
13
+ < MdxLink href = "https://github.com/gatsbyjs.gatsby" />
14
+ )
15
+ expect ( container . firstChild . nodeName ) . toBe ( "A" )
16
+ } )
17
+
18
+ it ( "creates a raw link on hashes" , ( ) => {
19
+ const { container } = render ( < MdxLink href = "#gatsby" /> )
20
+ expect ( container . firstChild . nodeName ) . toBe ( "A" )
21
+ } )
22
+
23
+ it ( "creates a raw link on files" , ( ) => {
24
+ const { container } = render ( < MdxLink href = "/gatsby-cheat-sheet.pdf" /> )
25
+ expect ( container . firstChild . nodeName ) . toBe ( "A" )
26
+ } )
27
+
28
+ it ( "creates a localized link for internal links" , ( ) => {
29
+ const { container } = render ( < MdxLink href = "/docs" /> )
30
+ expect ( container . firstChild . nodeName ) . toBe ( "SPAN" )
31
+ } )
32
+ } )
You can’t perform that action at this time.
0 commit comments