forked from vuejs/vue-test-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
142 lines (114 loc) · 4.54 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import Vue, { VNode, VNodeData, ComponentOptions, FunctionalComponentOptions } from 'vue'
// TODO: use core repo's Component type after https://github.com/vuejs/vue/pull/7369 is released
export type Component =
| typeof Vue
| FunctionalComponentOptions<{}>
| ComponentOptions<never, {}, {}, {}, {}>
/**
* Utility type to declare an extended Vue constructor
*/
type VueClass<V extends Vue> = (new (...args: any[]) => V) & typeof Vue
/**
* Utility type for a selector
*/
type Selector = string | Component
/**
* Utility type for slots
*/
type Slots = {
[key: string]: (Component | string)[] | Component | string
}
/**
* Utility type for stubs which can be a string of template as a shorthand
* If it is an array of string, the specified children are replaced by blank components
*/
type Stubs = {
[key: string]: Component | string | true
} | string[]
/**
* Utility type for ref options object that can be used as a Selector
*/
type RefSelector = {
ref: string
}
/**
* Base class of Wrapper and WrapperArray
* It has common methods on both Wrapper and WrapperArray
*/
interface BaseWrapper {
contains (selector: Selector): boolean
exists (): boolean
attributes(): { [name: string]: string } | void
classes(): Array<string> | void
props(): { [name: string]: any } | void
hasAttribute (attribute: string, value: string): boolean
hasClass (className: string): boolean
hasProp (prop: string, value: any): boolean
hasStyle (style: string, value: string): boolean
is (selector: Selector): boolean
isEmpty (): boolean
isVueInstance (): boolean
update (): void
setComputed (computed: object): void
setData (data: object): void
setMethods (data: object): void
setProps (props: object): void
trigger (eventName: string, options?: object): void
destroy (): void
}
interface Wrapper<V extends Vue> extends BaseWrapper {
readonly vm: V
readonly element: HTMLElement
readonly options: WrapperOptions
find<R extends Vue> (selector: VueClass<R>): Wrapper<R>
find<R extends Vue> (selector: ComponentOptions<R>): Wrapper<R>
find (selector: FunctionalComponentOptions): Wrapper<Vue>
find (selector: string): Wrapper<Vue>
find (selector: RefSelector): Wrapper<Vue>
findAll<R extends Vue> (selector: VueClass<R>): WrapperArray<R>
findAll<R extends Vue> (selector: ComponentOptions<R>): WrapperArray<R>
findAll (selector: FunctionalComponentOptions): WrapperArray<Vue>
findAll (selector: string): WrapperArray<Vue>
findAll (selector: RefSelector): WrapperArray<Vue>
html (): string
text (): string
name (): string
emitted (event?: string): { [name: string]: Array<Array<any>> }
emittedByOrder (): Array<{ name: string, args: Array<any> }>
}
interface WrapperArray<V extends Vue> extends BaseWrapper {
readonly length: number
readonly wrappers: Array<Wrapper<V>>
at (index: number): Wrapper<V>
}
interface WrapperOptions {
attachedToDocument: boolean
}
interface MountOptions<V extends Vue> extends ComponentOptions<V> {
attachToDocument?: boolean
context?: VNodeData
localVue?: typeof Vue
mocks?: object
slots?: Slots
stubs?: Stubs,
attrs?: object
listeners?: object
}
type ThisTypedMountOptions<V extends Vue> = MountOptions<V> & ThisType<V>
type ShallowOptions<V extends Vue> = MountOptions<V>
type ThisTypedShallowOptions<V extends Vue> = ShallowOptions<V> & ThisType<V>
interface VueTestUtilsConfigOptions {
stubs?: Stubs
}
export declare function createLocalVue (): typeof Vue
export declare function createWrapper (node: VNode | Component, update?: Function, options?: WrapperOptions): Wrapper<Vue>
export declare function createWrapperArray<T extends Vue> (wrappers: Array<Wrapper<T>>): WrapperArray<T>
export declare let config: VueTestUtilsConfigOptions
export declare function mount<V extends Vue> (component: VueClass<V>, options?: ThisTypedMountOptions<V>): Wrapper<V>
export declare function mount<V extends Vue> (component: ComponentOptions<V>, options?: ThisTypedMountOptions<V>): Wrapper<V>
export declare function mount (component: FunctionalComponentOptions, options?: MountOptions<Vue>): Wrapper<Vue>
export declare function shallow<V extends Vue> (component: VueClass<V>, options?: ThisTypedShallowOptions<V>): Wrapper<V>
export declare function shallow<V extends Vue> (component: ComponentOptions<V>, options?: ThisTypedShallowOptions<V>): Wrapper<V>
export declare function shallow (component: FunctionalComponentOptions, options?: ShallowOptions<Vue>): Wrapper<Vue>
export declare let TransitionStub: Component | string | true
export declare let TransitionGroupStub: Component | string | true