fix: responsiveObserve init miss sizing (#20400)

* fix: init miss sizing

* update mock test
pull/20290/head
二货机器人 5 years ago committed by GitHub
parent 8501b708ea
commit 4047e2632e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -77,6 +77,8 @@ const responsiveObserve = {
mql,
listener,
};
listener(mql);
});
},
};

@ -10,15 +10,6 @@ describe('Descriptions', () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
jest.spyOn(window, 'matchMedia').mockImplementationOnce(query => ({
addListener: (listener) => {
if (query === '(max-width: 575px)') {
listener({ matches: true });
}
},
removeListener: jest.fn(),
}));
afterEach(() => {
MockDate.reset();
errorSpy.mockReset();

@ -3,15 +3,6 @@ import { render, mount } from 'enzyme';
import { Col, Row } from '..';
import mountTest from '../../../tests/shared/mountTest';
jest.spyOn(window, 'matchMedia').mockImplementationOnce(query => ({
addListener: (listener) => {
if (query === '(max-width: 575px)') {
listener({ matches: true });
}
},
removeListener: jest.fn(),
}));
describe('Grid', () => {
mountTest(Row);
mountTest(Col);

@ -12,10 +12,10 @@ if (typeof window !== 'undefined') {
};
global.window.scrollTo = () => {};
// ref: https://github.com/ant-design/ant-design/issues/18774
if (!global.window.matchMedia) {
if (!window.matchMedia) {
Object.defineProperty(global.window, 'matchMedia', {
value: jest.fn(() => ({
matches: true,
value: jest.fn(query => ({
matches: query.includes('max-width'),
addListener: () => {},
removeListener: () => {},
})),

Loading…
Cancel
Save