diff --git a/typings/index.d.ts b/typings/index.d.ts index 604b8838..f69f75c4 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1,88 +1,14 @@ -import {Simulate as ReactSimulate} from 'react-dom/test-utils' -import { - AllByAttribute, - AllByText, - BoundFunction, - GetByAttribute, - GetByText, - QueryByAttribute, - QueryByText, -} from 'dom-testing-library' -export {prettyDOM} from 'dom-testing-library' +import {getQueriesForElement} from 'dom-testing-library' -type TextMatchFunction = (content: string, element: HTMLElement) => boolean -type TextMatch = string | RegExp | TextMatchFunction -type TextMatchOptions = { - exact?: boolean - trim?: boolean - collapseWhitespace?: boolean -} - -interface GetsAndQueries { - queryByPlaceholderText: BoundFunction - queryAllByPlaceholderText: BoundFunction - getByPlaceholderText: BoundFunction - getAllByPlaceholderText: BoundFunction - queryByText: BoundFunction - queryAllByText: BoundFunction - getByText: BoundFunction - getAllByText: BoundFunction - queryByLabelText: BoundFunction - queryAllByLabelText: BoundFunction - getByLabelText: BoundFunction - getAllByLabelText: BoundFunction - queryByAltText: BoundFunction - queryAllByAltText: BoundFunction - getByAltText: BoundFunction - getAllByAltText: BoundFunction - queryByTestId: BoundFunction - queryAllByTestId: BoundFunction - getByTestId: BoundFunction - getAllByTestId: BoundFunction - queryByTitle: BoundFunction - queryAllByTitle: BoundFunction - getByTitle: BoundFunction - getAllByTitle: BoundFunction - queryByValue: BoundFunction - queryAllByValue: BoundFunction - getByValue: BoundFunction - getAllByValue: BoundFunction -} +export * from 'dom-testing-library' -export const queryByPlaceholderText: QueryByAttribute -export const queryAllByPlaceholderText: AllByAttribute -export const getByPlaceholderText: GetByAttribute -export const getAllByPlaceholderText: AllByAttribute -export const queryByText: QueryByText -export const queryAllByText: AllByText -export const getByText: GetByText -export const getAllByText: AllByText -export const queryByLabelText: QueryByText -export const queryAllByLabelText: AllByText -export const getByLabelText: GetByText -export const getAllByLabelText: AllByText -export const queryByAltText: QueryByAttribute -export const queryAllByAltText: AllByAttribute -export const getByAltText: GetByAttribute -export const getAllByAltText: AllByAttribute -export const queryByTestId: QueryByAttribute -export const queryAllByTestId: AllByAttribute -export const getByTestId: GetByAttribute -export const getAllByTestId: AllByAttribute -export const queryByTitle: QueryByAttribute -export const queryAllByTitle: AllByAttribute -export const getByTitle: GetByAttribute -export const getAllByTitle: AllByAttribute -export const queryByValue: QueryByAttribute -export const queryAllByValue: AllByAttribute -export const getByValue: GetByAttribute -export const getAllByValue: AllByAttribute +type GetsAndQueries = ReturnType export interface RenderResult extends GetsAndQueries { container: HTMLDivElement debug: () => void rerender: (ui: React.ReactElement) => void - unmount: VoidFunction + unmount: () => boolean } /** @@ -93,113 +19,7 @@ export function render( options?: {container: HTMLElement; baseElement: HTMLElement}, ): RenderResult -/** - * When in need to wait for DOM elements to appear, disappear, or change. Prefer waitForElement. - */ -export function wait( - callback?: () => void, - options?: { - timeout?: number - interval?: number - }, -): Promise - -/** - * When in need to wait for DOM elements to appear, disappear, or change. - */ -export function waitForElement( - callback?: () => T, - options?: { - container?: HTMLElement - timeout?: number - mutationObserverOptions?: MutationObserverInit - }, -): Promise - -type EventType = - | 'copy' - | 'cut' - | 'paste' - | 'compositionEnd' - | 'compositionStart' - | 'compositionUpdate' - | 'keyDown' - | 'keyPress' - | 'keyUp' - | 'focus' - | 'blur' - | 'change' - | 'input' - | 'invalid' - | 'submit' - | 'click' - | 'contextMenu' - | 'dblClick' - | 'drag' - | 'dragEnd' - | 'dragEnter' - | 'dragExit' - | 'dragLeave' - | 'dragOver' - | 'dragStart' - | 'drop' - | 'mouseDown' - | 'mouseEnter' - | 'mouseLeave' - | 'mouseMove' - | 'mouseOut' - | 'mouseOver' - | 'mouseUp' - | 'select' - | 'touchCancel' - | 'touchEnd' - | 'touchMove' - | 'touchStart' - | 'scroll' - | 'wheel' - | 'abort' - | 'canPlay' - | 'canPlayThrough' - | 'durationChange' - | 'emptied' - | 'encrypted' - | 'ended' - | 'loadedData' - | 'loadedMetadata' - | 'loadStart' - | 'pause' - | 'play' - | 'playing' - | 'progress' - | 'rateChange' - | 'seeked' - | 'seeking' - | 'stalled' - | 'suspend' - | 'timeUpdate' - | 'volumeChange' - | 'waiting' - | 'load' - | 'error' - | 'animationStart' - | 'animationEnd' - | 'animationIteration' - | 'transitionEnd' - | 'doubleClick' - -type FireFunction = (element: HTMLElement, event: Event) => boolean -type FireObject = { - [K in EventType]: (element: HTMLElement, options?: {}) => boolean -} - -/** - * Fire DOM events. - */ -export const fireEvent: FireFunction & FireObject - /** * Unmounts React trees that were mounted with render. */ export function cleanup(): void - -export function getQueriesForElement(element: HTMLElement): GetsAndQueries