test: mock matchMedia
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
鲁树人 2023-06-10 00:55:10 +01:00
parent 740c5196aa
commit 470adc74db

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(),
}),
});