mirror of
https://github.com/ant-design/ant-design.git
synced 2025-07-31 20:36:35 +08:00
fix popconfirm test case
This commit is contained in:
parent
d95fbad0b2
commit
cee67bccda
@ -3,6 +3,11 @@ import { mount } from 'enzyme';
|
|||||||
import Popconfirm from '..';
|
import Popconfirm from '..';
|
||||||
|
|
||||||
describe('Popconfirm', () => {
|
describe('Popconfirm', () => {
|
||||||
|
const eventObject = expect.objectContaining({
|
||||||
|
target: expect.anything(),
|
||||||
|
preventDefault: expect.any(Function),
|
||||||
|
});
|
||||||
|
|
||||||
it('should popup Popconfirm dialog', () => {
|
it('should popup Popconfirm dialog', () => {
|
||||||
const onVisibleChange = jest.fn();
|
const onVisibleChange = jest.fn();
|
||||||
|
|
||||||
@ -21,11 +26,11 @@ describe('Popconfirm', () => {
|
|||||||
|
|
||||||
const triggerNode = wrapper.find('span').at(0);
|
const triggerNode = wrapper.find('span').at(0);
|
||||||
triggerNode.simulate('click');
|
triggerNode.simulate('click');
|
||||||
expect(onVisibleChange).toBeCalledWith(true);
|
expect(onVisibleChange).toHaveBeenLastCalledWith(true, undefined);
|
||||||
expect(wrapper.find('.popconfirm-test').length).toBe(1);
|
expect(wrapper.find('.popconfirm-test').length).toBe(1);
|
||||||
|
|
||||||
triggerNode.simulate('click');
|
triggerNode.simulate('click');
|
||||||
expect(onVisibleChange).toBeCalledWith(false);
|
expect(onVisibleChange).toHaveBeenLastCalledWith(false, undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show overlay when trigger is clicked', () => {
|
it('should show overlay when trigger is clicked', () => {
|
||||||
@ -76,11 +81,11 @@ describe('Popconfirm', () => {
|
|||||||
triggerNode.simulate('click');
|
triggerNode.simulate('click');
|
||||||
popconfirm.find('.ant-btn-primary').simulate('click');
|
popconfirm.find('.ant-btn-primary').simulate('click');
|
||||||
expect(confirm).toHaveBeenCalled();
|
expect(confirm).toHaveBeenCalled();
|
||||||
expect(onVisibleChange).toHaveBeenLastCalledWith(false);
|
expect(onVisibleChange).toHaveBeenLastCalledWith(false, eventObject);
|
||||||
triggerNode.simulate('click');
|
triggerNode.simulate('click');
|
||||||
popconfirm.find('.ant-btn').at(0).simulate('click');
|
popconfirm.find('.ant-btn').at(0).simulate('click');
|
||||||
expect(cancel).toHaveBeenCalled();
|
expect(cancel).toHaveBeenCalled();
|
||||||
expect(onVisibleChange).toHaveBeenLastCalledWith(false);
|
expect(onVisibleChange).toHaveBeenLastCalledWith(false, eventObject);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support customize icon', () => {
|
it('should support customize icon', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user