mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-16 01:41:02 +08:00
6493db80d4
* feat: drawer support ConfigConsumer.getPopupContainer and getPrefixCls * update snapshot * add getPopupContainer test
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import ConfigProvider from '..';
|
|
import DatePicker from '../../date-picker';
|
|
import Slider from '../../slider';
|
|
import Drawer from '../../drawer';
|
|
|
|
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();
|
|
});
|
|
});
|