forked from testing-library/react-hooks-testing-library
-
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.
Merge pull request #1 from stephenkilbourn/stephenkilbourn-fix-ssr-after
feat: add test to reproduce testing-library#605
- Loading branch information
Showing
4 changed files
with
20,865 additions
and
12 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,22 @@ | ||
/** | ||
* @jest-environment node | ||
*/ | ||
import {useState} from 'react' | ||
import {renderHook, act} from '..' | ||
|
||
// This verifies that renderHook can be called in | ||
// a SSR-like environment. | ||
describe('renderHook', () => { | ||
function useLoading() { | ||
if (typeof window !== 'undefined') { | ||
const [loading, setLoading] = useState(false) | ||
return {loading, setLoading} | ||
} | ||
} | ||
|
||
test('should not throw in SSR environment', () => { | ||
expect(() => renderHook(() => useLoading())).not.toThrowError( | ||
'document is not defined', | ||
) | ||
}) | ||
}) |
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
Oops, something went wrong.