mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 09:26:06 +08:00
fix: responsiveObserve init miss sizing (#20400)
* fix: init miss sizing * update mock test
This commit is contained in:
parent
8501b708ea
commit
4047e2632e
@ -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…
Reference in New Issue
Block a user