forked from testing-library/vue-testing-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
90 lines (78 loc) · 2.51 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Minimum TypeScript Version: 4.0
/* eslint-disable @typescript-eslint/no-explicit-any */
import {VNodeChild} from 'vue'
import {MountingOptions} from '@vue/test-utils'
import {queries, EventType, BoundFunctions} from '@testing-library/dom'
// eslint-disable-next-line import/no-extraneous-dependencies
import {OptionsReceived as PrettyFormatOptions} from 'pretty-format'
import {ComponentProps, ComponentSlots} from 'vue-component-type-helpers'
import {RemoveIndexSignature} from 'type-fest'
// NOTE: fireEvent is overridden below
export * from '@testing-library/dom'
export function cleanup(): void
type Debug = (
baseElement?: Array<DocumentFragment | Element> | DocumentFragment | Element,
maxLength?: number,
options?: PrettyFormatOptions,
) => void
export interface RenderResult extends BoundFunctions<typeof queries> {
container: Element
baseElement: Element
debug: Debug
unmount(): void
html(): string
emitted<T = unknown>(): Record<string, T[]>
emitted<T = unknown>(name?: string): T[]
rerender(props: object): Promise<void>
}
type VueTestUtilsRenderOptions = Omit<
MountingOptions<Record<string, any>>,
'attachTo' | 'propsData' | 'shallow'
>
interface VueTestingLibraryRenderOptions {
/**
* @deprecated Add a Vuex instance through `global.plugins` array instead.
*/
store?: any
/**
* @deprecated Add a Router instance through `global.plugins` array instead.
*/
routes?: any
container?: Element
baseElement?: Element
}
type AllowNonFunctionSlots<Slots> = {
[K in keyof Slots]: Slots[K] | VNodeChild
}
type ExtractSlots<C> = AllowNonFunctionSlots<
Partial<RemoveIndexSignature<ComponentSlots<C>>>
>
export interface RenderOptions<C>
extends Omit<
VueTestingLibraryRenderOptions & VueTestUtilsRenderOptions,
'props' | 'slots'
> {
props?: ComponentProps<C>
slots?: ExtractSlots<C>
}
export function render<C>(
TestComponent: C,
options?: RenderOptions<C>,
): RenderResult
export type AsyncFireObject = {
[K in EventType]: (
element: Document | Element | Window,
options?: {},
) => Promise<void>
}
export interface VueFireEventObject extends AsyncFireObject {
(element: Document | Element | Window, event: Event): Promise<void>
touch(element: Document | Element | Window): Promise<void>
update(element: HTMLOptionElement): Promise<void>
update(
element: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement,
value: string,
): Promise<void>
update(element: Element, value?: string): Promise<void>
}
export const fireEvent: VueFireEventObject