From 1c2d64be3edbb17df22c2ac7ec87991f0b59ac77 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 7 May 2021 09:30:34 +0800 Subject: [PATCH] types: add onClick event shim (#8665) --- src/count-down/test/index.spec.js | 16 ++++++++-------- src/utils/with-install.ts | 11 ++++++++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/count-down/test/index.spec.js b/src/count-down/test/index.spec.js index e43a32f51..f860019f0 100644 --- a/src/count-down/test/index.spec.js +++ b/src/count-down/test/index.spec.js @@ -86,8 +86,8 @@ test('should start counting after calling the start method', async () => { wrapper.vm.start(); await later(50); - const laterShapShot = wrapper.html(); - expect(prevSnapShot).not.toEqual(laterShapShot); + const laterSnapShot = wrapper.html(); + expect(prevSnapShot).not.toEqual(laterSnapShot); }); test('should pause counting after calling the pause method', async () => { @@ -102,9 +102,9 @@ test('should pause counting after calling the pause method', async () => { const prevSnapShot = wrapper.html(); wrapper.vm.pause(); await later(50); - const laterShapShot = wrapper.html(); + const laterSnapShot = wrapper.html(); - expect(prevSnapShot).toEqual(laterShapShot); + expect(prevSnapShot).toEqual(laterSnapShot); }); test('should reset time after calling the reset method', async () => { @@ -123,9 +123,9 @@ test('should reset time after calling the reset method', async () => { await later(50); wrapper.vm.reset(); await nextTick(); - const laterShapShot = wrapper.html(); + const laterSnapShot = wrapper.html(); - expect(prevSnapShot).toEqual(laterShapShot); + expect(prevSnapShot).toEqual(laterSnapShot); }); test('should format complete time correctly', () => { @@ -197,8 +197,8 @@ test('should pause counting when deactivated', async () => { await later(50); await wrapper.setData({ render: true }); - const laterShapShot = wrapper.html(); - expect(prevSnapShot).toEqual(laterShapShot); + const laterSnapShot = wrapper.html(); + expect(prevSnapShot).toEqual(laterSnapShot); }); test('should emit change event when counting', async () => { diff --git a/src/utils/with-install.ts b/src/utils/with-install.ts index 3423366dd..a0c5f984c 100644 --- a/src/utils/with-install.ts +++ b/src/utils/with-install.ts @@ -1,9 +1,18 @@ import { App } from 'vue'; import { camelize } from './format/string'; +// https://github.com/youzan/vant/issues/8302 +type EventShim = { + new (...args: any[]): { + $props: { + onClick?: (...args: any[]) => void; + }; + }; +}; + export type WithInstall = T & { install(app: App): void; -}; +} & EventShim; // using any here because tsc will generate some weird results when using generics export function withInstall(options: any): WithInstall {