Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Window {
- export const get = () => window
- }
- const Comp = () => {
- useEffect(() => {
- // handle siÄ™ nigdy nie wykona :(
- const handle = () => {}
- Window.get().addEventListener('keypress', handle)
- return () => Window.get().removeEventListener('keypress', handle)
- }, [])
- }
- describe('Comp', () => {
- beforeEach(() => {
- spyOn(Window, 'get').and.returnValue(document.body)
- })
- it('calls keypress', () => {
- Window.get().dispatchEvent(new KeyboardEvent('keypress'))
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement