Sha256: d16f1c460b1ca9158e030fdf3641e1de11135e0c7169d3e8cf17cc4cc35d5e64

Contents?: true

Size: 1.95 KB

Versions: 26

Compression:

Stored size: 1.95 KB

Contents

import {Matcher, MatcherOptions} from './matches'
import {waitForOptions} from './wait-for'

export type WithSuggest = {suggest?: boolean}

export type GetErrorFunction<Arguments extends any[] = [string]> = (
  c: Element | null,
  ...args: Arguments
) => string

export interface SelectorMatcherOptions extends MatcherOptions {
  selector?: string
  ignore?: boolean | string
}

export type QueryByAttribute = (
  attribute: string,
  container: HTMLElement,
  id: Matcher,
  options?: MatcherOptions,
) => HTMLElement | null

export type AllByAttribute = (
  attribute: string,
  container: HTMLElement,
  id: Matcher,
  options?: MatcherOptions,
) => HTMLElement[]

export const queryByAttribute: QueryByAttribute
export const queryAllByAttribute: AllByAttribute
export function getElementError(
  message: string | null,
  container: HTMLElement,
): Error

/**
 * query methods have a common call signature. Only the return type differs.
 */
export type QueryMethod<Arguments extends any[], Return> = (
  container: HTMLElement,
  ...args: Arguments
) => Return
export type QueryBy<Arguments extends any[]> = QueryMethod<
  Arguments,
  HTMLElement | null
>
export type GetAllBy<Arguments extends any[]> = QueryMethod<
  Arguments,
  HTMLElement[]
>
export type FindAllBy<Arguments extends any[]> = QueryMethod<
  [Arguments[0], Arguments[1]?, waitForOptions?],
  Promise<HTMLElement[]>
>
export type GetBy<Arguments extends any[]> = QueryMethod<Arguments, HTMLElement>
export type FindBy<Arguments extends any[]> = QueryMethod<
  [Arguments[0], Arguments[1]?, waitForOptions?],
  Promise<HTMLElement>
>

export type BuiltQueryMethods<Arguments extends any[]> = [
  QueryBy<Arguments>,
  GetAllBy<Arguments>,
  GetBy<Arguments>,
  FindAllBy<Arguments>,
  FindBy<Arguments>,
]

export function buildQueries<Arguments extends any[]>(
  queryAllBy: GetAllBy<Arguments>,
  getMultipleError: GetErrorFunction<Arguments>,
  getMissingError: GetErrorFunction<Arguments>,
): BuiltQueryMethods<Arguments>

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.25 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.24 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.23 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.22 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.21 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.20 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.19 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.18 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.17 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.16 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.15 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.14 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.13 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.12 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.11 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.10 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.9 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.8 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts
clapton-0.0.7 lib/clapton/javascripts/node_modules/@testing-library/dom/types/query-helpers.d.ts