From cee67bccdae9471e6528a788d0f4a496f62cbf68 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 8 Sep 2018 15:32:10 +0800 Subject: [PATCH] fix popconfirm test case --- components/popconfirm/__tests__/index.test.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/components/popconfirm/__tests__/index.test.js b/components/popconfirm/__tests__/index.test.js index 32f9368718..15e28a48b4 100644 --- a/components/popconfirm/__tests__/index.test.js +++ b/components/popconfirm/__tests__/index.test.js @@ -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', () => {