ant-design/components/config-provider/__tests__/container.test.js

48 lines
1.5 KiB
JavaScript
Raw Normal View History

import { mount } from 'enzyme';
2022-06-22 14:57:09 +08:00
import React from 'react';
import ConfigProvider from '..';
2022-06-22 14:57:09 +08:00
import Cascader from '../../cascader';
import DatePicker from '../../date-picker';
import Drawer from '../../drawer';
2022-06-22 14:57:09 +08:00
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 = ({ visible }) => (
<ConfigProvider getPopupContainer={getPopupContainer}>
<Drawer visible={visible} />
</ConfigProvider>
);
mount(<Demo visible />);
expect(getPopupContainer).toHaveBeenCalled();
});
it('Cascader', () => {
const getPopupContainer = jest.fn(node => node.parentNode);
mount(<Cascader getPopupContainer={getPopupContainer} open />);
expect(getPopupContainer).toHaveBeenCalled();
});
});