mirror of
https://github.com/kremalicious/portfolio.git
synced 2024-12-23 01:29:41 +01:00
28 lines
758 B
TypeScript
28 lines
758 B
TypeScript
|
const matchMediaMock = Object.defineProperty(window, 'matchMedia', {
|
||
|
writable: true,
|
||
|
value: jest
|
||
|
.fn()
|
||
|
.mockImplementationOnce((query) => ({
|
||
|
matches: false,
|
||
|
media: query,
|
||
|
onchange: null,
|
||
|
addListener: jest.fn(), // deprecated
|
||
|
removeListener: jest.fn(), // deprecated
|
||
|
addEventListener: jest.fn(),
|
||
|
removeEventListener: jest.fn(),
|
||
|
dispatchEvent: jest.fn()
|
||
|
}))
|
||
|
.mockImplementation((query) => ({
|
||
|
matches: true,
|
||
|
media: query,
|
||
|
onchange: null,
|
||
|
addListener: jest.fn(), // deprecated
|
||
|
removeListener: jest.fn(), // deprecated
|
||
|
addEventListener: jest.fn(),
|
||
|
removeEventListener: jest.fn(),
|
||
|
dispatchEvent: jest.fn()
|
||
|
}))
|
||
|
})
|
||
|
|
||
|
export default matchMediaMock
|