diff --git a/types/queries.d.ts b/types/queries.d.ts index 1d20f0b5..0917f8e5 100644 --- a/types/queries.d.ts +++ b/types/queries.d.ts @@ -1,70 +1,70 @@ -import {Matcher, MatcherOptions, ByRoleMatcher} from './matches' +import {ByRoleMatcher, Matcher, MatcherOptions} from './matches' import {SelectorMatcherOptions} from './query-helpers' import {waitForOptions} from './wait-for' -export type QueryByBoundAttribute = ( +export type QueryByBoundAttribute = ( container: HTMLElement, id: Matcher, options?: MatcherOptions, -) => HTMLElement | null +) => T | null -export type AllByBoundAttribute = ( +export type AllByBoundAttribute = ( container: HTMLElement, id: Matcher, options?: MatcherOptions, -) => HTMLElement[] +) => T[] -export type FindAllByBoundAttribute = ( +export type FindAllByBoundAttribute = ( container: HTMLElement, id: Matcher, options?: MatcherOptions, waitForElementOptions?: waitForOptions, -) => Promise +) => Promise -export type GetByBoundAttribute = ( +export type GetByBoundAttribute = ( container: HTMLElement, id: Matcher, options?: MatcherOptions, -) => HTMLElement +) => T -export type FindByBoundAttribute = ( +export type FindByBoundAttribute = ( container: HTMLElement, id: Matcher, options?: MatcherOptions, waitForElementOptions?: waitForOptions, -) => Promise +) => Promise -export type QueryByText = ( +export type QueryByText = ( container: HTMLElement, id: Matcher, options?: SelectorMatcherOptions, -) => HTMLElement | null +) => T | null -export type AllByText = ( +export type AllByText = ( container: HTMLElement, id: Matcher, options?: SelectorMatcherOptions, -) => HTMLElement[] +) => T[] -export type FindAllByText = ( +export type FindAllByText = ( container: HTMLElement, id: Matcher, options?: SelectorMatcherOptions, waitForElementOptions?: waitForOptions, -) => Promise +) => Promise -export type GetByText = ( +export type GetByText = ( container: HTMLElement, id: Matcher, options?: SelectorMatcherOptions, -) => HTMLElement +) => T -export type FindByText = ( +export type FindByText = ( container: HTMLElement, id: Matcher, options?: SelectorMatcherOptions, waitForElementOptions?: waitForOptions, -) => Promise +) => Promise export interface ByRoleOptions extends MatcherOptions { /** @@ -117,83 +117,179 @@ export interface ByRoleOptions extends MatcherOptions { | ((accessibleName: string, element: Element) => boolean) } -export type AllByRole = ( +export type AllByRole = ( container: HTMLElement, role: ByRoleMatcher, options?: ByRoleOptions, -) => HTMLElement[] +) => T[] -export type GetByRole = ( +export type GetByRole = ( container: HTMLElement, role: ByRoleMatcher, options?: ByRoleOptions, -) => HTMLElement +) => T -export type QueryByRole = ( +export type QueryByRole = ( container: HTMLElement, role: ByRoleMatcher, options?: ByRoleOptions, -) => HTMLElement | null +) => T | null -export type FindByRole = ( +export type FindByRole = ( container: HTMLElement, role: ByRoleMatcher, options?: ByRoleOptions, waitForElementOptions?: waitForOptions, -) => Promise +) => Promise -export type FindAllByRole = ( +export type FindAllByRole = ( container: HTMLElement, role: ByRoleMatcher, options?: ByRoleOptions, waitForElementOptions?: waitForOptions, -) => Promise - -export const getByLabelText: GetByText -export const getAllByLabelText: AllByText -export const queryByLabelText: QueryByText -export const queryAllByLabelText: AllByText -export const findByLabelText: FindByText -export const findAllByLabelText: FindAllByText -export const getByPlaceholderText: GetByBoundAttribute -export const getAllByPlaceholderText: AllByBoundAttribute -export const queryByPlaceholderText: QueryByBoundAttribute -export const queryAllByPlaceholderText: AllByBoundAttribute -export const findByPlaceholderText: FindByBoundAttribute -export const findAllByPlaceholderText: FindAllByBoundAttribute -export const getByText: GetByText -export const getAllByText: AllByText -export const queryByText: QueryByText -export const queryAllByText: AllByText -export const findByText: FindByText -export const findAllByText: FindAllByText -export const getByAltText: GetByBoundAttribute -export const getAllByAltText: AllByBoundAttribute -export const queryByAltText: QueryByBoundAttribute -export const queryAllByAltText: AllByBoundAttribute -export const findByAltText: FindByBoundAttribute -export const findAllByAltText: FindAllByBoundAttribute -export const getByTitle: GetByBoundAttribute -export const getAllByTitle: AllByBoundAttribute -export const queryByTitle: QueryByBoundAttribute -export const queryAllByTitle: AllByBoundAttribute -export const findByTitle: FindByBoundAttribute -export const findAllByTitle: FindAllByBoundAttribute -export const getByDisplayValue: GetByBoundAttribute -export const getAllByDisplayValue: AllByBoundAttribute -export const queryByDisplayValue: QueryByBoundAttribute -export const queryAllByDisplayValue: AllByBoundAttribute -export const findByDisplayValue: FindByBoundAttribute -export const findAllByDisplayValue: FindAllByBoundAttribute -export const getByRole: GetByRole -export const getAllByRole: AllByRole -export const queryByRole: QueryByRole -export const queryAllByRole: AllByRole -export const findByRole: FindByRole -export const findAllByRole: FindAllByRole -export const getByTestId: GetByBoundAttribute -export const getAllByTestId: AllByBoundAttribute -export const queryByTestId: QueryByBoundAttribute -export const queryAllByTestId: AllByBoundAttribute -export const findByTestId: FindByBoundAttribute -export const findAllByTestId: FindAllByBoundAttribute +) => Promise + +export function getByLabelText( + ...args: Parameters> +): ReturnType> +export function getAllByLabelText( + ...args: Parameters> +): ReturnType> +export function queryByLabelText( + ...args: Parameters> +): ReturnType> +export function queryAllByLabelText( + ...args: Parameters> +): ReturnType> +export function findByLabelText( + ...args: Parameters> +): ReturnType> +export function findAllByLabelText( + ...args: Parameters> +): ReturnType> +export function getByPlaceholderText( + ...args: Parameters> +): ReturnType> +export function getAllByPlaceholderText( + ...args: Parameters> +): ReturnType> +export function queryByPlaceholderText( + ...args: Parameters> +): ReturnType> +export function queryAllByPlaceholderText( + ...args: Parameters> +): ReturnType> +export function findByPlaceholderText( + ...args: Parameters> +): ReturnType> +export function findAllByPlaceholderText( + ...args: Parameters> +): ReturnType> +export function getByText( + ...args: Parameters> +): ReturnType> +export function getAllByText( + ...args: Parameters> +): ReturnType> +export function queryByText( + ...args: Parameters> +): ReturnType> +export function queryAllByText( + ...args: Parameters> +): ReturnType> +export function findByText( + ...args: Parameters> +): ReturnType> +export function findAllByText( + ...args: Parameters> +): ReturnType> +export function getByAltText( + ...args: Parameters> +): ReturnType> +export function getAllByAltText( + ...args: Parameters> +): ReturnType> +export function queryByAltText( + ...args: Parameters> +): ReturnType> +export function queryAllByAltText( + ...args: Parameters> +): ReturnType> +export function findByAltText( + ...args: Parameters> +): ReturnType> +export function findAllByAltText( + ...args: Parameters> +): ReturnType> +export function getByTitle( + ...args: Parameters> +): ReturnType> +export function getAllByTitle( + ...args: Parameters> +): ReturnType> +export function queryByTitle( + ...args: Parameters> +): ReturnType> +export function queryAllByTitle( + ...args: Parameters> +): ReturnType> +export function findByTitle( + ...args: Parameters> +): ReturnType> +export function findAllByTitle( + ...args: Parameters> +): ReturnType> +export function getByDisplayValue( + ...args: Parameters> +): ReturnType> +export function getAllByDisplayValue( + ...args: Parameters> +): ReturnType> +export function queryByDisplayValue( + ...args: Parameters> +): ReturnType> +export function queryAllByDisplayValue( + ...args: Parameters> +): ReturnType> +export function findByDisplayValue( + ...args: Parameters> +): ReturnType> +export function findAllByDisplayValue( + ...args: Parameters> +): ReturnType> +export function getByRole( + ...args: Parameters> +): ReturnType> +export function getAllByRole( + ...args: Parameters> +): ReturnType> +export function queryByRole( + ...args: Parameters> +): ReturnType> +export function queryAllByRole( + ...args: Parameters> +): ReturnType> +export function findByRole( + ...args: Parameters> +): ReturnType> +export function findAllByRole( + ...args: Parameters> +): ReturnType> +export function getByTestId( + ...args: Parameters> +): ReturnType> +export function getAllByTestId( + ...args: Parameters> +): ReturnType> +export function queryByTestId( + ...args: Parameters> +): ReturnType> +export function queryAllByTestId( + ...args: Parameters> +): ReturnType> +export function findByTestId( + ...args: Parameters> +): ReturnType> +export function findAllByTestId( + ...args: Parameters> +): ReturnType>