test: mock matchMedia configurable (#38034)

This commit is contained in:
MadCcc 2022-10-14 19:58:24 +08:00 committed by GitHub
parent 2ef701be75
commit 92a32998ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,8 @@ if (typeof window !== 'undefined') {
// ref: https://github.com/ant-design/ant-design/issues/18774
if (!window.matchMedia) {
Object.defineProperty(global.window, 'matchMedia', {
writable: true,
configurable: true,
value: jest.fn(query => ({
matches: query.includes('max-width'),
addListener: jest.fn(),