Created
January 20, 2017 16:55
-
-
Save elevine/69a27e067032c53d64d66f4f56e978cc to your computer and use it in GitHub Desktop.
Jest mock for the react-virtualized AutoSizer component
This file contains hidden or 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
| // __mocks__/react-virtualized.js | |
| // note - at the top of your test file, include this line: jest.mock('react-virtualized'); | |
| import React from 'react'; | |
| const reactVirtualized = jest.genMockFromModule('react-virtualized'); | |
| const autoSizerProps = { | |
| height: 100, | |
| width: 100 | |
| } | |
| const MockAutoSizer = ( props ) => { | |
| return <div> { props.children(autoSizerProps) } </div>; | |
| }; | |
| reactVirtualized.AutoSizer = MockAutoSizer; | |
| module.exports = reactVirtualized; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you installed only the
auto-sizersub-module, then you can use this code which is written using TypeScript and ES6 modules: