ant-design/components/config-provider/__tests__/container.test.tsx
lijianan db0344c85f
test: migrate part of ConfigProvider tests (#37142)
* test: migrate part of ConfigProvider tests

* test: migrate part of ConfigProvider tests

* test: update snap

* test: update snap

* test: migrate part of ConfigProvider tests

* fix: commented error case

* chore: update snapshot name

* test: csp test case

* test: revert test case

* test: Update snapshot

* test: Update ser logic

* test: more cov

* test: cascader snapshit

* test: update match

* test: more detact

* test: more handler

* chore: Update snapshot

* test: Table test case

Co-authored-by: 二货机器人 <smith3816@gmail.com>
2022-08-22 22:54:38 +08:00

48 lines
1.5 KiB
TypeScript

import React from 'react';
import ConfigProvider from '..';
import Cascader from '../../cascader';
import DatePicker from '../../date-picker';
import Drawer from '../../drawer';
import Slider from '../../slider';
import { render, fireEvent } from '../../../tests/utils';
describe('ConfigProvider.GetPopupContainer', () => {
it('Datepicker', () => {
const getPopupContainer = jest.fn(node => node.parentNode);
render(
<ConfigProvider getPopupContainer={getPopupContainer}>
<DatePicker open />
</ConfigProvider>,
);
expect(getPopupContainer).toHaveBeenCalled();
});
it('Slider', () => {
const getPopupContainer = jest.fn(node => node.parentNode);
const wrapper = render(
<ConfigProvider getPopupContainer={getPopupContainer}>
<Slider />
</ConfigProvider>,
);
fireEvent.mouseEnter(wrapper.container.querySelector('.ant-slider-handle')!);
expect(getPopupContainer).toHaveBeenCalled();
});
it('Drawer', () => {
const getPopupContainer = jest.fn(node => node.parentNode);
const Demo: React.FC<{ visible?: boolean }> = ({ visible }) => (
<ConfigProvider getPopupContainer={getPopupContainer}>
<Drawer visible={visible} />
</ConfigProvider>
);
render(<Demo visible />);
expect(getPopupContainer).toHaveBeenCalled();
});
it('Cascader', () => {
const getPopupContainer = jest.fn(node => node.parentNode);
render(<Cascader getPopupContainer={getPopupContainer} open />);
expect(getPopupContainer).toHaveBeenCalled();
});
});