mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +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 '..';
|
||||
|
||||
describe('Popconfirm', () => {
|
||||
const eventObject = expect.objectContaining({
|
||||
target: expect.anything(),
|
||||
preventDefault: expect.any(Function),
|
||||
});
|
||||
|
||||
it('should popup Popconfirm dialog', () => {
|
||||
const onVisibleChange = jest.fn();
|
||||
|
||||
@ -21,11 +26,11 @@ describe('Popconfirm', () => {
|
||||
|
||||
const triggerNode = wrapper.find('span').at(0);
|
||||
triggerNode.simulate('click');
|
||||
expect(onVisibleChange).toBeCalledWith(true);
|
||||
expect(onVisibleChange).toHaveBeenLastCalledWith(true, undefined);
|
||||
expect(wrapper.find('.popconfirm-test').length).toBe(1);
|
||||
|
||||
triggerNode.simulate('click');
|
||||
expect(onVisibleChange).toBeCalledWith(false);
|
||||
expect(onVisibleChange).toHaveBeenLastCalledWith(false, undefined);
|
||||
});
|
||||
|
||||
it('should show overlay when trigger is clicked', () => {
|
||||
@ -76,11 +81,11 @@ describe('Popconfirm', () => {
|
||||
triggerNode.simulate('click');
|
||||
popconfirm.find('.ant-btn-primary').simulate('click');
|
||||
expect(confirm).toHaveBeenCalled();
|
||||
expect(onVisibleChange).toHaveBeenLastCalledWith(false);
|
||||
expect(onVisibleChange).toHaveBeenLastCalledWith(false, eventObject);
|
||||
triggerNode.simulate('click');
|
||||
popconfirm.find('.ant-btn').at(0).simulate('click');
|
||||
expect(cancel).toHaveBeenCalled();
|
||||
expect(onVisibleChange).toHaveBeenLastCalledWith(false);
|
||||
expect(onVisibleChange).toHaveBeenLastCalledWith(false, eventObject);
|
||||
});
|
||||
|
||||
it('should support customize icon', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user