forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure link can render without router (vercel#15604)
This ensures rendering `next/link` doesn't fail without being nested under the router context. Closes: vercel#15543
- Loading branch information
1 parent
074c0ca
commit d2e4757
Showing
2 changed files
with
24 additions
and
3 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
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,20 @@ | ||
/* eslint-env jest */ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom/server' | ||
import Link from 'next/link' | ||
|
||
describe('Link rendering', () => { | ||
it('should render Link on its own', async () => { | ||
const element = React.createElement( | ||
Link, | ||
{ | ||
href: '/my-path', | ||
}, | ||
React.createElement('a', {}, 'to another page') | ||
) | ||
const html = ReactDOM.renderToString(element) | ||
expect(html).toMatchInlineSnapshot( | ||
`"<a href=\\"/my-path\\" data-reactroot=\\"\\">to another page</a>"` | ||
) | ||
}) | ||
}) |