Skip to content

Commit

Permalink
fix: mocking match media in global jest
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanad94 committed Jul 25, 2024
1 parent e123fe7 commit 03c7907
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
10 changes: 10 additions & 0 deletions jest/global-setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
window.matchMedia =
window.matchMedia ||
function () {
return {
matches: false,
addListener() {},
removeListener() {},
}
}

require('isomorphic-fetch')
15 changes: 0 additions & 15 deletions packages/sn-controls-react/test/reference-grid.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/* eslint-disable import/first */
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(),
})),
})

import Avatar from '@material-ui/core/Avatar'
import Dialog from '@material-ui/core/Dialog'
import IconButton from '@material-ui/core/IconButton'
Expand Down

0 comments on commit 03c7907

Please sign in to comment.