|
1 | 1 | import * as queries from './queries'
|
2 | 2 |
|
3 | 3 | export type BoundFunction<T> = T extends (
|
4 |
| - attribute: string, |
5 |
| - element: HTMLElement, |
6 |
| - text: infer P, |
7 |
| - options: infer Q, |
| 4 | + container: HTMLElement, |
| 5 | + ...args: infer P |
8 | 6 | ) => infer R
|
9 |
| - ? (text: P, options?: Q) => R |
10 |
| - : T extends ( |
11 |
| - a1: any, |
12 |
| - text: infer P, |
13 |
| - options: infer Q, |
14 |
| - waitForElementOptions: infer W, |
15 |
| - ) => infer R |
16 |
| - ? (text: P, options?: Q, waitForElementOptions?: W) => R |
17 |
| - : T extends (a1: any, text: infer P, options: infer Q) => infer R |
18 |
| - ? (text: P, options?: Q) => R |
| 7 | + ? (...args: P) => R |
19 | 8 | : never
|
20 |
| -export type BoundFunctions<T> = {[P in keyof T]: BoundFunction<T[P]>} |
| 9 | + |
| 10 | +export type BoundFunctions<Q> = Q extends typeof queries |
| 11 | + ? { |
| 12 | + getByLabelText<T extends HTMLElement = HTMLElement>( |
| 13 | + ...args: Parameters<BoundFunction<queries.GetByText<T>>> |
| 14 | + ): ReturnType<queries.GetByText<T>> |
| 15 | + getAllByLabelText<T extends HTMLElement = HTMLElement>( |
| 16 | + ...args: Parameters<BoundFunction<queries.AllByText<T>>> |
| 17 | + ): ReturnType<queries.AllByText<T>> |
| 18 | + queryByLabelText<T extends HTMLElement = HTMLElement>( |
| 19 | + ...args: Parameters<BoundFunction<queries.QueryByText<T>>> |
| 20 | + ): ReturnType<queries.QueryByText<T>> |
| 21 | + queryAllByLabelText<T extends HTMLElement = HTMLElement>( |
| 22 | + ...args: Parameters<BoundFunction<queries.AllByText<T>>> |
| 23 | + ): ReturnType<queries.AllByText<T>> |
| 24 | + findByLabelText<T extends HTMLElement = HTMLElement>( |
| 25 | + ...args: Parameters<BoundFunction<queries.FindByText<T>>> |
| 26 | + ): ReturnType<queries.FindByText<T>> |
| 27 | + findAllByLabelText<T extends HTMLElement = HTMLElement>( |
| 28 | + ...args: Parameters<BoundFunction<queries.FindAllByText<T>>> |
| 29 | + ): ReturnType<queries.FindAllByText<T>> |
| 30 | + getByPlaceholderText<T extends HTMLElement = HTMLElement>( |
| 31 | + ...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>> |
| 32 | + ): ReturnType<queries.GetByBoundAttribute<T>> |
| 33 | + getAllByPlaceholderText<T extends HTMLElement = HTMLElement>( |
| 34 | + ...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>> |
| 35 | + ): ReturnType<queries.AllByBoundAttribute<T>> |
| 36 | + queryByPlaceholderText<T extends HTMLElement = HTMLElement>( |
| 37 | + ...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>> |
| 38 | + ): ReturnType<queries.QueryByBoundAttribute<T>> |
| 39 | + queryAllByPlaceholderText<T extends HTMLElement = HTMLElement>( |
| 40 | + ...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>> |
| 41 | + ): ReturnType<queries.AllByBoundAttribute<T>> |
| 42 | + findByPlaceholderText<T extends HTMLElement = HTMLElement>( |
| 43 | + ...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>> |
| 44 | + ): ReturnType<queries.FindByBoundAttribute<T>> |
| 45 | + findAllByPlaceholderText<T extends HTMLElement = HTMLElement>( |
| 46 | + ...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>> |
| 47 | + ): ReturnType<queries.FindAllByBoundAttribute<T>> |
| 48 | + getByText<T extends HTMLElement = HTMLElement>( |
| 49 | + ...args: Parameters<BoundFunction<queries.GetByText<T>>> |
| 50 | + ): ReturnType<queries.GetByText<T>> |
| 51 | + getAllByText<T extends HTMLElement = HTMLElement>( |
| 52 | + ...args: Parameters<BoundFunction<queries.AllByText<T>>> |
| 53 | + ): ReturnType<queries.AllByText<T>> |
| 54 | + queryByText<T extends HTMLElement = HTMLElement>( |
| 55 | + ...args: Parameters<BoundFunction<queries.QueryByText<T>>> |
| 56 | + ): ReturnType<queries.QueryByText<T>> |
| 57 | + queryAllByText<T extends HTMLElement = HTMLElement>( |
| 58 | + ...args: Parameters<BoundFunction<queries.AllByText<T>>> |
| 59 | + ): ReturnType<queries.AllByText<T>> |
| 60 | + findByText<T extends HTMLElement = HTMLElement>( |
| 61 | + ...args: Parameters<BoundFunction<queries.FindByText<T>>> |
| 62 | + ): ReturnType<queries.FindByText<T>> |
| 63 | + findAllByText<T extends HTMLElement = HTMLElement>( |
| 64 | + ...args: Parameters<BoundFunction<queries.FindAllByText<T>>> |
| 65 | + ): ReturnType<queries.FindAllByText<T>> |
| 66 | + getByAltText<T extends HTMLElement = HTMLElement>( |
| 67 | + ...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>> |
| 68 | + ): ReturnType<queries.GetByBoundAttribute<T>> |
| 69 | + getAllByAltText<T extends HTMLElement = HTMLElement>( |
| 70 | + ...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>> |
| 71 | + ): ReturnType<queries.AllByBoundAttribute<T>> |
| 72 | + queryByAltText<T extends HTMLElement = HTMLElement>( |
| 73 | + ...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>> |
| 74 | + ): ReturnType<queries.QueryByBoundAttribute<T>> |
| 75 | + queryAllByAltText<T extends HTMLElement = HTMLElement>( |
| 76 | + ...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>> |
| 77 | + ): ReturnType<queries.AllByBoundAttribute<T>> |
| 78 | + findByAltText<T extends HTMLElement = HTMLElement>( |
| 79 | + ...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>> |
| 80 | + ): ReturnType<queries.FindByBoundAttribute<T>> |
| 81 | + findAllByAltText<T extends HTMLElement = HTMLElement>( |
| 82 | + ...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>> |
| 83 | + ): ReturnType<queries.FindAllByBoundAttribute<T>> |
| 84 | + getByTitle<T extends HTMLElement = HTMLElement>( |
| 85 | + ...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>> |
| 86 | + ): ReturnType<queries.GetByBoundAttribute<T>> |
| 87 | + getAllByTitle<T extends HTMLElement = HTMLElement>( |
| 88 | + ...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>> |
| 89 | + ): ReturnType<queries.AllByBoundAttribute<T>> |
| 90 | + queryByTitle<T extends HTMLElement = HTMLElement>( |
| 91 | + ...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>> |
| 92 | + ): ReturnType<queries.QueryByBoundAttribute<T>> |
| 93 | + queryAllByTitle<T extends HTMLElement = HTMLElement>( |
| 94 | + ...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>> |
| 95 | + ): ReturnType<queries.AllByBoundAttribute<T>> |
| 96 | + findByTitle<T extends HTMLElement = HTMLElement>( |
| 97 | + ...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>> |
| 98 | + ): ReturnType<queries.FindByBoundAttribute<T>> |
| 99 | + findAllByTitle<T extends HTMLElement = HTMLElement>( |
| 100 | + ...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>> |
| 101 | + ): ReturnType<queries.FindAllByBoundAttribute<T>> |
| 102 | + getByDisplayValue<T extends HTMLElement = HTMLElement>( |
| 103 | + ...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>> |
| 104 | + ): ReturnType<queries.GetByBoundAttribute<T>> |
| 105 | + getAllByDisplayValue<T extends HTMLElement = HTMLElement>( |
| 106 | + ...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>> |
| 107 | + ): ReturnType<queries.AllByBoundAttribute<T>> |
| 108 | + queryByDisplayValue<T extends HTMLElement = HTMLElement>( |
| 109 | + ...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>> |
| 110 | + ): ReturnType<queries.QueryByBoundAttribute<T>> |
| 111 | + queryAllByDisplayValue<T extends HTMLElement = HTMLElement>( |
| 112 | + ...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>> |
| 113 | + ): ReturnType<queries.AllByBoundAttribute<T>> |
| 114 | + findByDisplayValue<T extends HTMLElement = HTMLElement>( |
| 115 | + ...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>> |
| 116 | + ): ReturnType<queries.FindByBoundAttribute<T>> |
| 117 | + findAllByDisplayValue<T extends HTMLElement = HTMLElement>( |
| 118 | + ...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>> |
| 119 | + ): ReturnType<queries.FindAllByBoundAttribute<T>> |
| 120 | + getByRole<T extends HTMLElement = HTMLElement>( |
| 121 | + ...args: Parameters<BoundFunction<queries.GetByRole<T>>> |
| 122 | + ): ReturnType<queries.GetByRole<T>> |
| 123 | + getAllByRole<T extends HTMLElement = HTMLElement>( |
| 124 | + ...args: Parameters<BoundFunction<queries.AllByRole<T>>> |
| 125 | + ): ReturnType<queries.AllByRole<T>> |
| 126 | + queryByRole<T extends HTMLElement = HTMLElement>( |
| 127 | + ...args: Parameters<BoundFunction<queries.QueryByRole<T>>> |
| 128 | + ): ReturnType<queries.QueryByRole<T>> |
| 129 | + queryAllByRole<T extends HTMLElement = HTMLElement>( |
| 130 | + ...args: Parameters<BoundFunction<queries.AllByRole<T>>> |
| 131 | + ): ReturnType<queries.AllByRole<T>> |
| 132 | + findByRole<T extends HTMLElement = HTMLElement>( |
| 133 | + ...args: Parameters<BoundFunction<queries.FindByRole<T>>> |
| 134 | + ): ReturnType<queries.FindByRole<T>> |
| 135 | + findAllByRole<T extends HTMLElement = HTMLElement>( |
| 136 | + ...args: Parameters<BoundFunction<queries.FindAllByRole<T>>> |
| 137 | + ): ReturnType<queries.FindAllByRole<T>> |
| 138 | + getByTestId<T extends HTMLElement = HTMLElement>( |
| 139 | + ...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>> |
| 140 | + ): ReturnType<queries.GetByBoundAttribute<T>> |
| 141 | + getAllByTestId<T extends HTMLElement = HTMLElement>( |
| 142 | + ...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>> |
| 143 | + ): ReturnType<queries.AllByBoundAttribute<T>> |
| 144 | + queryByTestId<T extends HTMLElement = HTMLElement>( |
| 145 | + ...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>> |
| 146 | + ): ReturnType<queries.QueryByBoundAttribute<T>> |
| 147 | + queryAllByTestId<T extends HTMLElement = HTMLElement>( |
| 148 | + ...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>> |
| 149 | + ): ReturnType<queries.AllByBoundAttribute<T>> |
| 150 | + findByTestId<T extends HTMLElement = HTMLElement>( |
| 151 | + ...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>> |
| 152 | + ): ReturnType<queries.FindByBoundAttribute<T>> |
| 153 | + findAllByTestId<T extends HTMLElement = HTMLElement>( |
| 154 | + ...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>> |
| 155 | + ): ReturnType<queries.FindAllByBoundAttribute<T>> |
| 156 | + } |
| 157 | + : { |
| 158 | + [P in keyof Q]: BoundFunction<Q[P]> |
| 159 | + } |
21 | 160 |
|
22 | 161 | export type Query = (
|
23 | 162 | container: HTMLElement,
|
|
0 commit comments