2020-04-25 22:46:21 +08:00
|
|
|
import { mount } from 'enzyme';
|
2022-06-22 14:57:09 +08:00
|
|
|
import React from 'react';
|
2020-04-25 22:46:21 +08:00
|
|
|
import ConfigProvider from '..';
|
2022-06-22 14:57:09 +08:00
|
|
|
import Cascader from '../../cascader';
|
2020-04-25 22:46:21 +08:00
|
|
|
import DatePicker from '../../date-picker';
|
2020-06-04 23:12:37 +08:00
|
|
|
import Drawer from '../../drawer';
|
2022-06-22 14:57:09 +08:00
|
|
|
import Slider from '../../slider';
|
2020-04-25 22:46:21 +08:00
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
2020-06-04 23:12:37 +08:00
|
|
|
|
2021-09-13 15:59:57 +08:00
|
|
|
it('Drawer', () => {
|
2020-06-04 23:12:37 +08:00
|
|
|
const getPopupContainer = jest.fn(node => node.parentNode);
|
2022-08-23 16:22:00 +08:00
|
|
|
const Demo = ({ open }) => (
|
2020-06-04 23:12:37 +08:00
|
|
|
<ConfigProvider getPopupContainer={getPopupContainer}>
|
2022-08-23 16:22:00 +08:00
|
|
|
<Drawer open={open} />
|
2020-06-04 23:12:37 +08:00
|
|
|
</ConfigProvider>
|
|
|
|
);
|
2022-08-23 16:22:00 +08:00
|
|
|
mount(<Demo open />);
|
2020-06-04 23:12:37 +08:00
|
|
|
expect(getPopupContainer).toHaveBeenCalled();
|
|
|
|
});
|
2021-09-13 15:59:57 +08:00
|
|
|
|
|
|
|
it('Cascader', () => {
|
|
|
|
const getPopupContainer = jest.fn(node => node.parentNode);
|
|
|
|
mount(<Cascader getPopupContainer={getPopupContainer} open />);
|
|
|
|
expect(getPopupContainer).toHaveBeenCalled();
|
|
|
|
});
|
2020-04-25 22:46:21 +08:00
|
|
|
});
|