|
| 1 | +// TypeScript Version: 3.0 |
| 2 | +import { ThisTypedMountOptions, VueClass } from '@vue/test-utils' |
| 3 | +import Vue from 'vue' |
| 4 | +import { Store, StoreOptions } from 'vuex' |
| 5 | +import Router, { RouterOptions, RouteConfig } from 'vue-router' |
| 6 | +import { getQueriesForElement, BoundFunctions, queries, EventType, FireFunction } from '@testing-library/dom' |
| 7 | + |
| 8 | +// NOTE: fireEvent is overridden below |
| 9 | +export * from '@testing-library/dom' |
| 10 | + |
| 11 | +export function cleanup(): void |
| 12 | + |
| 13 | +export interface RenderOptions<V extends Vue, S = {}> extends |
| 14 | + // The props and store options special-cased by vue-testing-library and NOT passed to mount(). |
| 15 | + // In TS 3.5+: Omit<ThisTypedMountOptions<V>, "store" | "props"> |
| 16 | + Pick<ThisTypedMountOptions<V>, Exclude<keyof ThisTypedMountOptions<V>, "store" | "props">> { |
| 17 | + props?: object |
| 18 | + store?: StoreOptions<S> |
| 19 | + routes?: RouteConfig[] |
| 20 | +} |
| 21 | + |
| 22 | +export type ConfigurationCallback<V extends Vue> = |
| 23 | + (vue: V, store: Store<any>, router: Router) => Partial<ThisTypedMountOptions<V>> | void |
| 24 | + |
| 25 | +export type ComponentHarness = BoundFunctions<typeof queries> & { |
| 26 | + container: HTMLElement |
| 27 | + baseElement: HTMLBodyElement |
| 28 | + debug(el?: HTMLElement): void |
| 29 | + unmount(): void |
| 30 | + isUnmounted(): boolean |
| 31 | + html(): string |
| 32 | + emitted(): { [name: string]: any[][] } |
| 33 | + updateProps(props: object): Promise<void> |
| 34 | +} |
| 35 | + |
| 36 | +export function render<V extends Vue>( |
| 37 | + TestComponent: VueClass<V>, |
| 38 | + options?: RenderOptions<V>, |
| 39 | + configure?: ConfigurationCallback<V> |
| 40 | +): ComponentHarness |
| 41 | + |
| 42 | +export type AsyncFireObject = { |
| 43 | + [K in EventType]: (element: Document | Element | Window, options?: {}) => Promise<void> |
| 44 | +} |
| 45 | + |
| 46 | +export interface VueFireObject extends AsyncFireObject { |
| 47 | + touch(element: Document | Element | Window): Promise<void> |
| 48 | + update(element: HTMLOptionElement): Promise<void> |
| 49 | + update(element: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, value?: string): Promise<void> |
| 50 | +} |
| 51 | + |
| 52 | +export const fireEvent: FireFunction & VueFireObject |
0 commit comments