|
1 |
| -import {Matcher, MatcherOptions, SelectorMatcherOptions, waitForOptions} from '@testing-library/dom' |
| 1 | +import { |
| 2 | + Matcher, |
| 3 | + MatcherOptions as MatcherOptions_, |
| 4 | + SelectorMatcherOptions as SelectorMatcherOptions_, |
| 5 | + waitForOptions, |
| 6 | +} from '@testing-library/dom' |
2 | 7 | import {ElementHandle as PlaywrightElementHandle} from 'playwright'
|
3 | 8 |
|
4 | 9 | export type ElementHandle = PlaywrightElementHandle<SVGElement | HTMLElement>
|
5 | 10 |
|
6 | 11 | type Element = ElementHandle
|
7 | 12 |
|
| 13 | +type MatcherOptions = Omit<MatcherOptions_, 'normalizer'> |
| 14 | +type SelectorMatcherOptions = Omit<SelectorMatcherOptions_, 'normalizer'> |
| 15 | + |
| 16 | +// tslint:disable-next-line |
| 17 | +interface RoleMatcherOptions extends MatcherOptions { |
| 18 | + name?: string | RegExp |
| 19 | +} |
| 20 | + |
| 21 | +// tslint:disable-next-line |
| 22 | +interface SelectorRoleMatcherOptions extends SelectorMatcherOptions { |
| 23 | + name?: string | RegExp |
| 24 | +} |
| 25 | + |
8 | 26 | interface IQueryMethods {
|
9 | 27 | queryByPlaceholderText(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element | null>
|
10 | 28 | queryAllByPlaceholderText(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element[]>
|
@@ -108,20 +126,20 @@ interface IQueryMethods {
|
108 | 126 | waitForOpts?: waitForOptions,
|
109 | 127 | ): Promise<Element[]>
|
110 | 128 |
|
111 |
| - queryByRole(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element | null> |
112 |
| - queryAllByRole(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element[]> |
113 |
| - getByRole(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element> |
114 |
| - getAllByRole(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element[]> |
| 129 | + queryByRole(el: Element, m: Matcher, opts?: RoleMatcherOptions): Promise<Element | null> |
| 130 | + queryAllByRole(el: Element, m: Matcher, opts?: RoleMatcherOptions): Promise<Element[]> |
| 131 | + getByRole(el: Element, m: Matcher, opts?: RoleMatcherOptions): Promise<Element> |
| 132 | + getAllByRole(el: Element, m: Matcher, opts?: RoleMatcherOptions): Promise<Element[]> |
115 | 133 | findByRole(
|
116 | 134 | el: Element,
|
117 | 135 | m: Matcher,
|
118 |
| - opts?: SelectorMatcherOptions, |
| 136 | + opts?: SelectorRoleMatcherOptions, |
119 | 137 | waitForOpts?: waitForOptions,
|
120 | 138 | ): Promise<Element>
|
121 | 139 | findAllByRole(
|
122 | 140 | el: Element,
|
123 | 141 | m: Matcher,
|
124 |
| - opts?: SelectorMatcherOptions, |
| 142 | + opts?: SelectorRoleMatcherOptions, |
125 | 143 | waitForOpts?: waitForOptions,
|
126 | 144 | ): Promise<Element[]>
|
127 | 145 |
|
@@ -150,8 +168,8 @@ export type BoundFunction<T> = T extends (
|
150 | 168 | options: infer Q,
|
151 | 169 | ) => infer R
|
152 | 170 | ? (text: P, options?: Q) => R
|
153 |
| - : T extends (a1: any, text: infer P, options: infer Q, waitForElementOptions: infer W) => infer R |
154 |
| - ? (text: P, options?: Q, waitForElementOptions?: W) => R |
| 171 | + : T extends (a1: any, text: infer P, options: infer Q, waitForOptions: infer W) => infer R |
| 172 | + ? (text: P, options?: Q, waitForOptions?: W) => R |
155 | 173 | : T extends (a1: any, text: infer P, options: infer Q) => infer R
|
156 | 174 | ? (text: P, options?: Q) => R
|
157 | 175 | : never
|
|
0 commit comments