mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 09:21:22 +08:00
766748a501
* feat: change visible to open for Drawer * refactor: use open internal either * feat: add warning when use visible * test: Fix test Co-authored-by: 二货机器人 <smith3816@gmail.com>
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
import { mount } from 'enzyme';
|
|
import React from 'react';
|
|
import ConfigProvider from '..';
|
|
import Cascader from '../../cascader';
|
|
import DatePicker from '../../date-picker';
|
|
import Drawer from '../../drawer';
|
|
import Slider from '../../slider';
|
|
|
|
describe('ConfigProvider.GetPopupContainer', () => {
|
|
it('Datepicker', () => {
|
|
const getPopupContainer = jest.fn(node => node.parentNode);
|
|
mount(
|
|
<ConfigProvider getPopupContainer={getPopupContainer}>
|
|
<DatePicker open />
|
|
</ConfigProvider>,
|
|
);
|
|
expect(getPopupContainer).toHaveBeenCalled();
|
|
});
|
|
|
|
it('Slider', () => {
|
|
const getPopupContainer = jest.fn(node => node.parentNode);
|
|
const wrapper = mount(
|
|
<ConfigProvider getPopupContainer={getPopupContainer}>
|
|
<Slider />
|
|
</ConfigProvider>,
|
|
);
|
|
wrapper.find('.ant-slider-handle').first().simulate('mouseenter');
|
|
expect(getPopupContainer).toHaveBeenCalled();
|
|
});
|
|
|
|
it('Drawer', () => {
|
|
const getPopupContainer = jest.fn(node => node.parentNode);
|
|
const Demo = ({ open }) => (
|
|
<ConfigProvider getPopupContainer={getPopupContainer}>
|
|
<Drawer open={open} />
|
|
</ConfigProvider>
|
|
);
|
|
mount(<Demo open />);
|
|
expect(getPopupContainer).toHaveBeenCalled();
|
|
});
|
|
|
|
it('Cascader', () => {
|
|
const getPopupContainer = jest.fn(node => node.parentNode);
|
|
mount(<Cascader getPopupContainer={getPopupContainer} open />);
|
|
expect(getPopupContainer).toHaveBeenCalled();
|
|
});
|
|
});
|