Skip to content

Commit

Permalink
fix(within): types should list custom and base queries (#1045)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Oct 4, 2021
1 parent 8c5c05d commit b28586e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions types/__tests__/type-tests.ts
Expand Up @@ -117,6 +117,21 @@ export async function testQueryHelpers() {
await findByAutomationId(element, ['id', 'id'], {})
await findAllByAutomationId(element, ['id', 'id'])
await findByAutomationId(element, ['id', 'id'])

const screenWithCustomQueries = within(document.body, {
...queries,
queryByAutomationId,
getAllByAutomationId,
getByAutomationId,
findAllByAutomationId,
findByAutomationId,
})

screenWithCustomQueries.queryByAutomationId('id')
screenWithCustomQueries.getAllByAutomationId('id')
screenWithCustomQueries.getByAutomationId(['id', 'automationId'])
await screenWithCustomQueries.findAllByAutomationId('id', {}, {timeout: 1000})
await screenWithCustomQueries.findByAutomationId('id', {}, {timeout: 1000})
}

export function testBoundFunctions() {
Expand Down
2 changes: 2 additions & 0 deletions types/get-queries-for-element.d.ts
Expand Up @@ -153,6 +153,8 @@ export type BoundFunctions<Q> = Q extends typeof queries
findAllByTestId<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>>
): ReturnType<queries.FindAllByBoundAttribute<T>>
} & {
[P in keyof Q]: BoundFunction<Q[P]>
}
: {
[P in keyof Q]: BoundFunction<Q[P]>
Expand Down

0 comments on commit b28586e

Please sign in to comment.