Created
October 15, 2019 19:29
-
-
Save jaysoo/e5902e8b59ee8b2850ddf8514ea7307f to your computer and use it in GitHub Desktop.
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
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { act } from '@testing-library/react'; | |
import { useViewportSize } from './use-viewport-size'; | |
describe(' UseViewportSize', () => { | |
it('should render successfully', () => { | |
// Setup | |
let container = document.createElement('div'); | |
document.body.appendChild(container); | |
const App = () => { | |
const size = useViewportSize(); | |
return <div>{JSON.stringify(size)}</div>; | |
}; | |
act(() => { | |
ReactDOM.render(<App />, container); | |
}); | |
expect(container.textContent).toEqual('{"width":1024,"height":768}'); | |
// Teardown | |
document.body.removeChild(container); | |
container = null; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment