Skip to content

Commit

Permalink
Feat #30 - Update: fix snapshot test bug (matchMedia)
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-dassana committed Aug 11, 2020
1 parent fecab62 commit a5f8523
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 14 additions & 0 deletions src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,17 @@ import Enzyme from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'

Enzyme.configure({ adapter: new Adapter() })

Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn()
}))
})
14 changes: 0 additions & 14 deletions src/storybook.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
import initStoryshots from '@storybook/addon-storyshots'

Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn()
}))
})

initStoryshots()

0 comments on commit a5f8523

Please sign in to comment.