34 lines
711 B
JavaScript
Raw Permalink Normal View History

2022-12-04 22:15:59 -05:00
if (typeof window === 'undefined') {
global.window = {
URL: {
createObjectURL: jest.fn(),
},
localStorage: {
removeItem: jest.fn(),
getItem: jest.fn(),
},
2022-12-11 09:03:53 -05:00
navigator: {
platform: 'Win',
},
matchMedia: () => ({
matches: false,
}),
2022-12-04 22:15:59 -05:00
};
}
2022-12-13 10:31:35 -05:00
global.URL.createObjectURL = jest.fn();
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(),
})),
});