Skip to content

Commit

Permalink
(test): ensure resize event fires
Browse files Browse the repository at this point in the history
  • Loading branch information
agilgur5 committed Mar 4, 2020
1 parent 73b6296 commit a2212c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion test/index.spec.ts
@@ -1,4 +1,4 @@
import { describe, it, expect } from 'jest-without-globals'
import { describe, it, expect, jest } from 'jest-without-globals'

import { resizeTo } from '../src/index'

Expand All @@ -16,4 +16,12 @@ describe('window resize ponyfill', () => {
expect({ width: window.outerWidth, height: window.outerHeight })
.toMatchObject(dimF2)
})

it('should fire an event', () => {
const resizeHandler = jest.fn()
window.addEventListener('resize', resizeHandler)
resizeTo(window, dimF1.width, dimF1.height)

expect(resizeHandler).toBeCalled()
})
})
10 changes: 9 additions & 1 deletion test/polyfill.spec.ts
@@ -1,4 +1,4 @@
import { describe, it, expect } from 'jest-without-globals'
import { describe, it, expect, jest } from 'jest-without-globals'

import '../src/polyfill'

Expand All @@ -16,4 +16,12 @@ describe('window resize polyfill', () => {
expect({ width: window.outerWidth, height: window.outerHeight })
.toMatchObject(dimF2)
})

it('should fire an event', () => {
const resizeHandler = jest.fn()
window.addEventListener('resize', resizeHandler)
window.resizeTo(dimF1.width, dimF1.height)

expect(resizeHandler).toBeCalled()
})
})

0 comments on commit a2212c8

Please sign in to comment.