Skip to content

Commit

Permalink
fix: BoundSyncFunctions type should contain query*, not find* (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas authored Oct 14, 2024
1 parent c3e71b2 commit b247386
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 49 deletions.
3 changes: 2 additions & 1 deletion src/renderStream/__tests__/createRenderStream.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ describe('snapshotDOM', () => {
}
{
const {withinDOM} = await takeRender()
const input = withinDOM().getByLabelText<HTMLInputElement>('Value')
// a one-off to test that `queryBy` works and accepts a type argument
const input = withinDOM().queryByLabelText<HTMLInputElement>('Value')!
expect(input.value).toBe('1')
}
{
Expand Down
90 changes: 42 additions & 48 deletions src/renderStream/syncQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,84 +31,84 @@ export type BoundSyncFunctions<Q> = Q extends typeof syncQueries
getAllByLabelText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByText<T>>>
): ReturnType<queries.AllByText<T>>
findByLabelText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindByText<T>>>
): ReturnType<queries.FindByText<T>>
findAllByLabelText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindAllByText<T>>>
): ReturnType<queries.FindAllByText<T>>
queryByLabelText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.QueryByText<T>>>
): ReturnType<queries.QueryByText<T>>
queryAllByLabelText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByText<T>>>
): ReturnType<queries.AllByText<T>>
getByPlaceholderText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>>
): ReturnType<queries.GetByBoundAttribute<T>>
getAllByPlaceholderText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
): ReturnType<queries.AllByBoundAttribute<T>>
findByPlaceholderText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>>
): ReturnType<queries.FindByBoundAttribute<T>>
findAllByPlaceholderText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>>
): ReturnType<queries.FindAllByBoundAttribute<T>>
queryByPlaceholderText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>>
): ReturnType<queries.QueryByBoundAttribute<T>>
queryAllByPlaceholderText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
): ReturnType<queries.AllByBoundAttribute<T>>
getByText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.GetByText<T>>>
): ReturnType<queries.GetByText<T>>
getAllByText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByText<T>>>
): ReturnType<queries.AllByText<T>>
findByText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindByText<T>>>
): ReturnType<queries.FindByText<T>>
findAllByText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindAllByText<T>>>
): ReturnType<queries.FindAllByText<T>>
queryByText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.QueryByText<T>>>
): ReturnType<queries.QueryByText<T>>
queryAllByText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByText<T>>>
): ReturnType<queries.AllByText<T>>
getByAltText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>>
): ReturnType<queries.GetByBoundAttribute<T>>
getAllByAltText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
): ReturnType<queries.AllByBoundAttribute<T>>
findByAltText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>>
): ReturnType<queries.FindByBoundAttribute<T>>
findAllByAltText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>>
): ReturnType<queries.FindAllByBoundAttribute<T>>
queryByAltText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>>
): ReturnType<queries.QueryByBoundAttribute<T>>
queryAllByAltText<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
): ReturnType<queries.AllByBoundAttribute<T>>
getByTitle<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>>
): ReturnType<queries.GetByBoundAttribute<T>>
getAllByTitle<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
): ReturnType<queries.AllByBoundAttribute<T>>
findByTitle<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>>
): ReturnType<queries.FindByBoundAttribute<T>>
findAllByTitle<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>>
): ReturnType<queries.FindAllByBoundAttribute<T>>
queryByTitle<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>>
): ReturnType<queries.QueryByBoundAttribute<T>>
queryAllByTitle<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
): ReturnType<queries.AllByBoundAttribute<T>>
getByDisplayValue<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>>
): ReturnType<queries.GetByBoundAttribute<T>>
getAllByDisplayValue<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
): ReturnType<queries.AllByBoundAttribute<T>>
findByDisplayValue<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>>
): ReturnType<queries.FindByBoundAttribute<T>>
findAllByDisplayValue<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>>
): ReturnType<queries.FindAllByBoundAttribute<T>>
queryByDisplayValue<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>>
): ReturnType<queries.QueryByBoundAttribute<T>>
queryAllByDisplayValue<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
): ReturnType<queries.AllByBoundAttribute<T>>
getByRole<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.GetByRole<T>>>
): ReturnType<queries.GetByRole<T>>
getAllByRole<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByRole<T>>>
): ReturnType<queries.AllByRole<T>>
findByRole<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindByRole<T>>>
): ReturnType<queries.FindByRole<T>>
findAllByRole<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindAllByRole<T>>>
): ReturnType<queries.FindAllByRole<T>>
queryByRole<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.QueryByRole<T>>>
): ReturnType<queries.QueryByRole<T>>
queryAllByRole<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByRole<T>>>
): ReturnType<queries.AllByRole<T>>
getByTestId<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>>
): ReturnType<queries.GetByBoundAttribute<T>>
Expand All @@ -121,12 +121,6 @@ export type BoundSyncFunctions<Q> = Q extends typeof syncQueries
queryAllByTestId<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
): ReturnType<queries.AllByBoundAttribute<T>>
findByTestId<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>>
): ReturnType<queries.FindByBoundAttribute<T>>
findAllByTestId<T extends HTMLElement = HTMLElement>(
...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>>
): ReturnType<queries.FindAllByBoundAttribute<T>>
} & {
[P in keyof Q]: BoundFunction<Q[P]>
}
Expand Down

0 comments on commit b247386

Please sign in to comment.