Skip to content

Commit b28586e

Browse files
authored
fix(within): types should list custom and base queries (#1045)
1 parent 8c5c05d commit b28586e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

types/__tests__/type-tests.ts

+15
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,21 @@ export async function testQueryHelpers() {
117117
await findByAutomationId(element, ['id', 'id'], {})
118118
await findAllByAutomationId(element, ['id', 'id'])
119119
await findByAutomationId(element, ['id', 'id'])
120+
121+
const screenWithCustomQueries = within(document.body, {
122+
...queries,
123+
queryByAutomationId,
124+
getAllByAutomationId,
125+
getByAutomationId,
126+
findAllByAutomationId,
127+
findByAutomationId,
128+
})
129+
130+
screenWithCustomQueries.queryByAutomationId('id')
131+
screenWithCustomQueries.getAllByAutomationId('id')
132+
screenWithCustomQueries.getByAutomationId(['id', 'automationId'])
133+
await screenWithCustomQueries.findAllByAutomationId('id', {}, {timeout: 1000})
134+
await screenWithCustomQueries.findByAutomationId('id', {}, {timeout: 1000})
120135
}
121136

122137
export function testBoundFunctions() {

types/get-queries-for-element.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ export type BoundFunctions<Q> = Q extends typeof queries
153153
findAllByTestId<T extends HTMLElement = HTMLElement>(
154154
...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>>
155155
): ReturnType<queries.FindAllByBoundAttribute<T>>
156+
} & {
157+
[P in keyof Q]: BoundFunction<Q[P]>
156158
}
157159
: {
158160
[P in keyof Q]: BoundFunction<Q[P]>

0 commit comments

Comments
 (0)