-
Notifications
You must be signed in to change notification settings - Fork 254
/
wrapperLike.ts
117 lines (103 loc) · 4 KB
/
wrapperLike.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
import { DomEventNameWithModifier } from '../constants/dom-events'
import { TriggerOptions } from '../createDomEvent'
import {
DefinedComponent,
FindAllComponentsSelector,
FindComponentSelector,
NameSelector,
RefSelector
} from '../types'
import { VueWrapper } from '../vueWrapper'
import { ComponentPublicInstance, FunctionalComponent } from 'vue'
import type { DOMWrapper } from '../domWrapper'
export default interface WrapperLike {
readonly element: Node
find<K extends keyof HTMLElementTagNameMap>(
selector: K
): DOMWrapper<HTMLElementTagNameMap[K]>
find<K extends keyof SVGElementTagNameMap>(
selector: K
): DOMWrapper<SVGElementTagNameMap[K]>
find<T extends Element = Element>(selector: string): DOMWrapper<T>
find<T extends Node = Node>(selector: string | RefSelector): DOMWrapper<T>
findAll<K extends keyof HTMLElementTagNameMap>(
selector: K
): DOMWrapper<HTMLElementTagNameMap[K]>[]
findAll<K extends keyof SVGElementTagNameMap>(
selector: K
): DOMWrapper<SVGElementTagNameMap[K]>[]
findAll<T extends Element>(selector: string): DOMWrapper<T>[]
findAll(selector: string): DOMWrapper<Element>[]
findComponent<T extends never>(selector: string): WrapperLike
findComponent<T extends DefinedComponent>(
selector: T | Exclude<FindComponentSelector, FunctionalComponent>
): VueWrapper<InstanceType<T>>
findComponent<T extends FunctionalComponent>(
selector: T | string
): DOMWrapper<Element>
findComponent<T extends never>(
selector: NameSelector | RefSelector
): VueWrapper
findComponent<T extends ComponentPublicInstance>(
selector: T | FindComponentSelector
): VueWrapper<T>
findComponent(selector: FindComponentSelector): WrapperLike
findAllComponents<T extends never>(selector: string): WrapperLike[]
findAllComponents<T extends DefinedComponent>(
selector: T | Exclude<FindAllComponentsSelector, FunctionalComponent>
): VueWrapper<InstanceType<T>>[]
findAllComponents<T extends FunctionalComponent>(
selector: string
): DOMWrapper<Element>[]
findAllComponents<T extends FunctionalComponent>(
selector: T
): DOMWrapper<Node>[]
findAllComponents<T extends never>(selector: NameSelector): VueWrapper[]
findAllComponents<T extends ComponentPublicInstance>(
selector: T | FindAllComponentsSelector
): VueWrapper<T>[]
findAllComponents(selector: FindAllComponentsSelector): WrapperLike[]
get<K extends keyof HTMLElementTagNameMap>(
selector: K
): Omit<DOMWrapper<HTMLElementTagNameMap[K]>, 'exists'>
get<K extends keyof SVGElementTagNameMap>(
selector: K
): Omit<DOMWrapper<SVGElementTagNameMap[K]>, 'exists'>
get<T extends Element = Element>(
selector: string
): Omit<DOMWrapper<T>, 'exists'>
get<T extends Node = Node>(
selector: string | RefSelector
): Omit<DOMWrapper<T>, 'exists'>
getComponent<T extends never>(selector: string): Omit<WrapperLike, 'exists'>
getComponent<T extends DefinedComponent>(
selector: T | Exclude<FindComponentSelector, FunctionalComponent>
): Omit<VueWrapper<InstanceType<T>>, 'exists'>
// searching for functional component results in DOMWrapper
getComponent<T extends FunctionalComponent>(
selector: T | string
): Omit<DOMWrapper<Element>, 'exists'>
getComponent<T extends ComponentPublicInstance>(
selector: T | FindComponentSelector
): Omit<VueWrapper<T>, 'exists'>
// catch all declaration
getComponent<T extends never>(
selector: FindComponentSelector
): Omit<WrapperLike, 'exists'>
html(): string
classes(): string[]
classes(className: string): boolean
classes(className?: string): string[] | boolean
attributes(): { [key: string]: string }
attributes(key: string): string | undefined
attributes(key?: string): { [key: string]: string } | string | undefined
text(): string
exists(): boolean
setValue(value: any): Promise<void>
isVisible(): boolean
trigger(
eventString: DomEventNameWithModifier,
options?: TriggerOptions
): Promise<void>
trigger(eventString: string, options?: TriggerOptions): Promise<void>
}