Advertisement
Guest User

Untitled

a guest
Jul 24th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace Window {
  2.  export const get = () => window
  3. }
  4.  
  5. const Comp = () => {
  6.  useEffect(() => {
  7.   // handle siÄ™ nigdy nie wykona :(
  8.   const handle = () => {}
  9.   Window.get().addEventListener('keypress', handle)
  10.   return () => Window.get().removeEventListener('keypress', handle)
  11.  }, [])
  12. }
  13.  
  14. describe('Comp', () => {
  15.  beforeEach(() => {
  16.   spyOn(Window, 'get').and.returnValue(document.body)
  17.  })
  18.  
  19.  it('calls keypress', () => {
  20.   Window.get().dispatchEvent(new KeyboardEvent('keypress'))
  21.  })
  22. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement