test: mock matchMedia

This commit is contained in:
鲁树人 2023-06-10 00:55:10 +01:00
parent 0c4b7f4048
commit 9abd73b212

View File

@ -15,3 +15,17 @@ if (!global.Worker) {
}
};
}
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: (query: string) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(), // deprecated
removeListener: vi.fn(), // deprecated
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
}),
});