mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-22 18:00:06 +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
|