mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
55c85f77a1
* deps: upgrade rc-menu, and close: #2837 * test: update snapshots * Update rc-calendar * Update rc-cascader * Update rc-dialog * Update dropdown * Update rc-select@7.1.0 * Update rc-slider * Update rc-time-picker * Update rc-tooltip * Update rc-tree-select * Mock rc-trigger and Portal * Fix animation warning when inlineCollapsed changes * fix: should use SubMenu[popupClassName] * Fix typescript error * Fix lint * fix: style for menu * Mock rc-trigger for React 15 * Remvoe allow_failures
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import Popconfirm from '..';
|
|
|
|
describe('Popconfirm', () => {
|
|
it('should popup Popconfirm dialog', () => {
|
|
const onVisibleChange = jest.fn();
|
|
|
|
const wrapper = mount(
|
|
<Popconfirm
|
|
title={<span className="popconfirm-test">Are you sure delete this task?</span>}
|
|
okText="Yes"
|
|
cancelText="No"
|
|
mouseEnterDelay={0}
|
|
mouseLeaveDelay={0}
|
|
onVisibleChange={onVisibleChange}
|
|
>
|
|
<span>Delete</span>
|
|
</Popconfirm>
|
|
);
|
|
|
|
const triggerNode = wrapper.find('span').at(0);
|
|
triggerNode.simulate('click');
|
|
expect(onVisibleChange).toBeCalledWith(true);
|
|
expect(wrapper.find('.popconfirm-test').length).toBe(1);
|
|
|
|
triggerNode.simulate('click');
|
|
expect(onVisibleChange).toBeCalledWith(false);
|
|
});
|
|
|
|
it('should show overlay when trigger is clicked', () => {
|
|
const popconfirm = mount(
|
|
<Popconfirm title="code">
|
|
<span>show me your code</span>
|
|
</Popconfirm>
|
|
);
|
|
|
|
expect(popconfirm.instance().getPopupDomNode()).toBe(null);
|
|
|
|
popconfirm.find('span').simulate('click');
|
|
|
|
const popup = popconfirm.instance().getPopupDomNode();
|
|
expect(popup).not.toBe(null);
|
|
expect(popup.className).toContain('ant-popover-placement-top');
|
|
expect(popup.innerHTML).toMatchSnapshot();
|
|
expect(popup.innerHTML).toMatchSnapshot();
|
|
});
|
|
});
|