-
Notifications
You must be signed in to change notification settings - Fork 933
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ssr): add type check for window (#205)
Also add tests to avoid breaking SSR in the future
- Loading branch information
Kent C. Dodds
authored
Sep 28, 2017
1 parent
e3935f2
commit 67f53de
Showing
3 changed files
with
33 additions
and
1 deletion.
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,20 @@ | ||
import React from 'react' | ||
import ReactDOMServer from 'react-dom/server' | ||
import Downshift from '../../../src' | ||
|
||
test('does not throw an error when server rendering', () => { | ||
expect(() => { | ||
ReactDOMServer.renderToString( | ||
<Downshift id="my-autocomplete-component"> | ||
{({getInputProps, getLabelProps}) => ( | ||
<div> | ||
<label {...getLabelProps({htmlFor: 'my-autocomplete-input'})} /> | ||
<input {...getInputProps({id: 'my-autocomplete-input'})} /> | ||
</div> | ||
)} | ||
</Downshift> | ||
) | ||
}).not.toThrow() | ||
}) | ||
|
||
/* eslint jsx-a11y/label-has-for:0 */ |
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,9 @@ | ||
// This is separate because the test environment is set via the config | ||
// and we want most of our tests to run with jsdom, but we still want | ||
// to make sure that the server rendering use case continues to work. | ||
const jestConfig = require('kcd-scripts/config').jest | ||
|
||
module.exports = Object.assign(jestConfig, { | ||
roots: ['.'], | ||
testEnvironment: 'node', | ||
}) |
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