vant/test/plugin.ts
2021-02-11 12:19:21 +08:00

27 lines
705 B
TypeScript

/* eslint-disable max-classes-per-file */
import { ComponentPublicInstance } from 'vue';
import { config, VueWrapper, DOMWrapper } from '@vue/test-utils';
declare module '@vue/test-utils' {
// eslint-disable-next-line
export class DOMWrapper<ElementType extends Element> {
style: CSSStyleDeclaration;
}
// eslint-disable-next-line
class VueWrapper<T extends ComponentPublicInstance> {
style: CSSStyleDeclaration;
}
}
const stylePlugin = (
wrapper: VueWrapper<ComponentPublicInstance> | DOMWrapper<Element>
) => {
return {
style: (wrapper.element as HTMLElement).style,
};
};
config.plugins.DOMWrapper.install(stylePlugin);
config.plugins.VueWrapper.install(stylePlugin);