mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-10 19:19:20 +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,
|
mql,
|
||||||
listener,
|
listener,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
listener(mql);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -10,15 +10,6 @@ describe('Descriptions', () => {
|
|||||||
|
|
||||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
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(() => {
|
afterEach(() => {
|
||||||
MockDate.reset();
|
MockDate.reset();
|
||||||
errorSpy.mockReset();
|
errorSpy.mockReset();
|
||||||
|
@ -3,15 +3,6 @@ import { render, mount } from 'enzyme';
|
|||||||
import { Col, Row } from '..';
|
import { Col, Row } from '..';
|
||||||
import mountTest from '../../../tests/shared/mountTest';
|
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', () => {
|
describe('Grid', () => {
|
||||||
mountTest(Row);
|
mountTest(Row);
|
||||||
mountTest(Col);
|
mountTest(Col);
|
||||||
|
@ -12,10 +12,10 @@ if (typeof window !== 'undefined') {
|
|||||||
};
|
};
|
||||||
global.window.scrollTo = () => {};
|
global.window.scrollTo = () => {};
|
||||||
// ref: https://github.com/ant-design/ant-design/issues/18774
|
// ref: https://github.com/ant-design/ant-design/issues/18774
|
||||||
if (!global.window.matchMedia) {
|
if (!window.matchMedia) {
|
||||||
Object.defineProperty(global.window, 'matchMedia', {
|
Object.defineProperty(global.window, 'matchMedia', {
|
||||||
value: jest.fn(() => ({
|
value: jest.fn(query => ({
|
||||||
matches: true,
|
matches: query.includes('max-width'),
|
||||||
addListener: () => {},
|
addListener: () => {},
|
||||||
removeListener: () => {},
|
removeListener: () => {},
|
||||||
})),
|
})),
|
||||||
|
Loading…
Reference in New Issue
Block a user