Skip to content

Commit

Permalink
Update flow-typed definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtnzlml authored and kodiakhq[bot] committed Apr 6, 2021
1 parent d3e2ac7 commit 2cd7530
Show file tree
Hide file tree
Showing 8 changed files with 565 additions and 2,402 deletions.
46 changes: 46 additions & 0 deletions flow-typed/npm/@testing-library/jest-dom_v5.5.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// flow-typed signature: 0c9447942a6ffdb5f79f218bfe8e58d9
// flow-typed version: fe9fda6713/@testing-library/jest-dom_v5.5.x/flow_>=v0.104.x

declare module '@testing-library/jest-dom' {
declare type JestMatcherResult = {
message?: string | (() => string),
pass: boolean,
...
};

declare type Result = JestMatcherResult | Promise<JestMatcherResult>;

declare module.exports: {|
/**
* @deprecated
*/
toBeInTheDOM(container?: HTMLElement): Result,

toBeInTheDocument(): Result,
toBeVisible(): Result,
toBeEmpty(): Result,
toBeDisabled(): Result,
toBeEnabled(): Result,
toBeInvalid(): Result,
toBeRequired(): Result,
toBeValid(): Result,
toContainElement(element: HTMLElement | null): Result,
toContainHTML(htmlText: string): Result,
toHaveAttribute(attr: string, value?: any): Result,
toHaveClass(...classNames: string[]): Result,
toHaveFocus(): Result,
toHaveFormValues(expectedValues: { [name: string]: any, ... }): Result,
toHaveStyle(css: string | { [name: string]: any, ... }): Result,
toHaveTextContent(
text: string | RegExp,
options?: {| normalizeWhitespace: boolean |}
): Result,
toHaveValue(value?: string | string[] | number): Result,
toHaveDisplayValue(value: string | string[]): Result,
toBeChecked(): Result,
|};
}

declare module '@testing-library/jest-dom/extend-expect' {
declare module.exports: any;
}
73 changes: 73 additions & 0 deletions flow-typed/npm/@testing-library/react-hooks_v3.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// flow-typed signature: d2327256a96d87ce8dfe5ef5ec7149e4
// flow-typed version: ec99079dbb/@testing-library/react-hooks_v3.x.x/flow_>=v0.104.x

// @flow
// Initially adapted from: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/testing-library__react-hooks.

declare module '@testing-library/react-hooks' {
declare export type RenderHookOptions<P> = {|
+initialProps?: P,
+wrapper?: React$ComponentType<{|
...P,
+children: React$Node,
|}>,
|};

declare export type WaitOptions = {|
+interval?: number,
+timeout?: number,
+suppressErrors?: boolean,
|};

declare type HookResult<R> = {|
+current: R,
+error?: Error,
|};

declare type RenderHookResult<P, R> = {|
+result: HookResult<R>,
+waitForNextUpdate: (
options?: $Diff<WaitOptions, $Diff<WaitOptions, {| +timeout?: number |}>>
) => Promise<void>,
+waitForValueToChange: (
selector: () => any,
options?: WaitOptions
) => Promise<void>,
+waitFor: (
callback: () => boolean | void,
options?: WaitOptions
) => Promise<void>,
+unmount: () => boolean,
+rerender: (newProps?: P) => void,
|};

// From `react-test-renderer`.
// See: https://github.com/flow-typed/flow-typed/blob/master/definitions/npm/react-test-renderer_v16.x.x/.

declare type Thenable = {
then(resolve: () => mixed, reject?: () => mixed): mixed,
...
};

/**
* To prepare a component for assertions, wrap the code rendering it and
* performing updates inside an act() call. This makes your test run closer to
* how React works in the browser.
*/
declare export function act(callback: () => void | Promise<void>): Thenable;

/**
* Renders a test component that will call the provided `callback`, including
* any hooks it calls, every time it renders.
*/
declare export function renderHook<P, R>(
callback: (props: P) => R,
options?: RenderHookOptions<P>
): RenderHookResult<P, R>;

/**
* Unmounts any rendered hooks rendered with `renderHook`, ensuring all
* effects have been flushed.
*/
declare export function cleanup(): Promise<void>;
}
Loading

0 comments on commit 2cd7530

Please sign in to comment.