2022-06-22 14:57:09 +08:00
|
|
|
import React from 'react';
|
2024-04-08 14:04:08 +08:00
|
|
|
|
2020-04-25 22:46:21 +08:00
|
|
|
import ConfigProvider from '..';
|
2023-06-07 11:54:50 +08:00
|
|
|
import { fireEvent, render } from '../../../tests/utils';
|
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', () => {
|
2023-06-07 21:59:21 +08:00
|
|
|
const getPopupContainer = jest.fn((node) => node.parentNode);
|
2022-08-22 22:54:38 +08:00
|
|
|
render(
|
2020-04-25 22:46:21 +08:00
|
|
|
<ConfigProvider getPopupContainer={getPopupContainer}>
|
|
|
|
<DatePicker open />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
expect(getPopupContainer).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Slider', () => {
|
2023-06-07 21:59:21 +08:00
|
|
|
const getPopupContainer = jest.fn((node) => node.parentNode);
|
2022-08-22 22:54:38 +08:00
|
|
|
const wrapper = render(
|
2020-04-25 22:46:21 +08:00
|
|
|
<ConfigProvider getPopupContainer={getPopupContainer}>
|
|
|
|
<Slider />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
2022-08-22 22:54:38 +08:00
|
|
|
fireEvent.mouseEnter(wrapper.container.querySelector('.ant-slider-handle')!);
|
2020-04-25 22:46:21 +08:00
|
|
|
expect(getPopupContainer).toHaveBeenCalled();
|
|
|
|
});
|
2020-06-04 23:12:37 +08:00
|
|
|
|
2021-09-13 15:59:57 +08:00
|
|
|
it('Drawer', () => {
|
2023-06-07 21:59:21 +08:00
|
|
|
const getPopupContainer = jest.fn((node) => node.parentNode);
|
2022-08-23 14:52:37 +08:00
|
|
|
const Demo: React.FC<{ open?: boolean }> = ({ open }) => (
|
2020-06-04 23:12:37 +08:00
|
|
|
<ConfigProvider getPopupContainer={getPopupContainer}>
|
2022-08-23 14:52:37 +08:00
|
|
|
<Drawer open={open} />
|
2020-06-04 23:12:37 +08:00
|
|
|
</ConfigProvider>
|
|
|
|
);
|
2022-08-23 14:52:37 +08:00
|
|
|
render(<Demo open />);
|
2020-06-04 23:12:37 +08:00
|
|
|
expect(getPopupContainer).toHaveBeenCalled();
|
|
|
|
});
|
2021-09-13 15:59:57 +08:00
|
|
|
|
|
|
|
it('Cascader', () => {
|
2023-06-07 21:59:21 +08:00
|
|
|
const getPopupContainer = jest.fn((node) => node.parentNode);
|
2022-08-22 22:54:38 +08:00
|
|
|
render(<Cascader getPopupContainer={getPopupContainer} open />);
|
2021-09-13 15:59:57 +08:00
|
|
|
expect(getPopupContainer).toHaveBeenCalled();
|
|
|
|
});
|
2020-04-25 22:46:21 +08:00
|
|
|
});
|