diff --git a/packages/overlay/index.tsx b/packages/overlay/index.tsx index dae07e1a2..bd6323de5 100644 --- a/packages/overlay/index.tsx +++ b/packages/overlay/index.tsx @@ -39,9 +39,6 @@ function Overlay( event.preventDefault(); event.stopPropagation(); }} - onClick={(event: Event) => { - emit(ctx, 'click', event); - }} {...inherit(ctx, true)} /> diff --git a/packages/popup/test/index.spec.js b/packages/popup/test/index.spec.js index 7c1b9558d..ac84619c5 100644 --- a/packages/popup/test/index.spec.js +++ b/packages/popup/test/index.spec.js @@ -146,12 +146,18 @@ test('watch overlay prop', () => { expect(div.querySelector('.van-overlay')).toBeTruthy(); }); -test('close on click modal', () => { +test('close on click overlay', () => { const div = document.createElement('div'); + const onClickOverlay = jest.fn(); + wrapper = mount({ template: `
- +
`, components: { @@ -162,13 +168,18 @@ test('close on click modal', () => { value: true, getContainer: () => div }; + }, + methods: { + onClickOverlay } }); const modal = div.querySelector('.van-overlay'); triggerDrag(modal, 0, -30); modal.click(); + expect(wrapper.vm.value).toBeFalsy(); + expect(onClickOverlay).toHaveBeenCalledTimes(1); }); test('oepn & close event', () => {