Skip to content

Commit

Permalink
test(global): change window for global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjoverm committed Jan 29, 2017
1 parent 0ce379c commit 665cc4e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ interface MockWindow extends Window {
removeEventListener: jest.Mock<{}> & typeof window.removeEventListener
}
function getMockWindow() {
window.addEventListener = jest.fn()
window.removeEventListener = jest.fn()
return window as MockWindow
let myGlobal = global as any
myGlobal.addEventListener = jest.fn()
myGlobal.removeEventListener = jest.fn()
return myGlobal
}

/**
Expand All @@ -20,7 +21,7 @@ function getMockWindow() {
describe('shortcutJS', () => {
let mockWindow = getMockWindow()

afterEach(() => {
beforeEach(() => {
shortcutJS.reset()

mockWindow.addEventListener.mockClear()
Expand Down

0 comments on commit 665cc4e

Please sign in to comment.