mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Update react-dom, react-test-renderer to 16.8.0
This commit is contained in:
parent
1f8e6dfd28
commit
58da7330ea
3
types/react-dom/index.d.ts
vendored
3
types/react-dom/index.d.ts
vendored
@ -1,10 +1,11 @@
|
||||
// Type definitions for React (react-dom) 16.0
|
||||
// Type definitions for React (react-dom) 16.8
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>
|
||||
// AssureSign <http://www.assuresign.com>
|
||||
// Microsoft <https://microsoft.com>
|
||||
// MartynasZilinskas <https://github.com/MartynasZilinskas>
|
||||
// Josh Rutherford <https://github.com/theruther4d>
|
||||
// Jessica Franco <https://github.com/Jessidhia>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
|
||||
@ -178,4 +178,18 @@ describe('React dom test utils', () => {
|
||||
shallowRenderer.getRenderOutput();
|
||||
});
|
||||
});
|
||||
|
||||
describe('act', () => {
|
||||
it('accepts a sync callback that is void', () => {
|
||||
ReactTestUtils.act(() => {});
|
||||
});
|
||||
it('rejects an async callback even if void', () => {
|
||||
// $ExpectError
|
||||
ReactTestUtils.act(async () => {});
|
||||
});
|
||||
it('rejects a callback that returns null', () => {
|
||||
// $ExpectError
|
||||
ReactTestUtils.act(() => null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
14
types/react-dom/test-utils/index.d.ts
vendored
14
types/react-dom/test-utils/index.d.ts
vendored
@ -278,3 +278,17 @@ export function findRenderedComponentWithType<T extends Component<any>, C extend
|
||||
* Call this in your tests to create a shallow renderer.
|
||||
*/
|
||||
export function createRenderer(): ShallowRenderer;
|
||||
|
||||
/**
|
||||
* Wrap any code rendering and triggering updates to your components into `act()` calls.
|
||||
*
|
||||
* Ensures that the behavior in your tests matches what happens in the browser
|
||||
* more closely by executing pending `useEffect`s before returning. This also
|
||||
* reduces the amount of re-renders done.
|
||||
*
|
||||
* @param callback A synchronous, void callback that will execute as a single, complete React commit.
|
||||
*
|
||||
* @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
|
||||
*/
|
||||
// the "void | undefined" is here to forbid any sneaky "Promise" returns.
|
||||
export function act(callback: () => void | undefined): void;
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
|
||||
17
types/react-test-renderer/index.d.ts
vendored
17
types/react-test-renderer/index.d.ts
vendored
@ -1,9 +1,10 @@
|
||||
// Type definitions for react-test-renderer 16.0
|
||||
// Type definitions for react-test-renderer 16.8
|
||||
// Project: https://facebook.github.io/react/
|
||||
// Definitions by: Arvitaly <https://github.com/arvitaly>
|
||||
// Lochbrunner <https://github.com/lochbrunner>
|
||||
// John Reilly <https://github.com/johnnyreilly>
|
||||
// John Gozde <https://github.com/jgoz>
|
||||
// Jessica Franco <https://github.com/Jessidhia>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@ -50,3 +51,17 @@ export interface TestRendererOptions {
|
||||
createNodeMock(element: ReactElement<any>): any;
|
||||
}
|
||||
export function create(nextElement: ReactElement<any>, options?: TestRendererOptions): ReactTestRenderer;
|
||||
|
||||
/**
|
||||
* Wrap any code rendering and triggering updates to your components into `act()` calls.
|
||||
*
|
||||
* Ensures that the behavior in your tests matches what happens in the browser
|
||||
* more closely by executing pending `useEffect`s before returning. This also
|
||||
* reduces the amount of re-renders done.
|
||||
*
|
||||
* @param callback A synchronous, void callback that will execute as a single, complete React commit.
|
||||
*
|
||||
* @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
|
||||
*/
|
||||
// the "void | undefined" is here to forbid any sneaky "Promise" returns.
|
||||
export function act(callback: () => void | undefined): void;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import * as React from "react";
|
||||
import { create, ReactTestInstance } from "react-test-renderer";
|
||||
import React = require("react");
|
||||
import { act, create, ReactTestInstance } from "react-test-renderer";
|
||||
import { createRenderer } from 'react-test-renderer/shallow';
|
||||
|
||||
class TestComponent extends React.Component { }
|
||||
@ -66,3 +66,10 @@ const shallowRenderer = createRenderer();
|
||||
shallowRenderer.render(component);
|
||||
shallowRenderer.getRenderOutput();
|
||||
shallowRenderer.getMountedInstance();
|
||||
|
||||
// Only synchronous, void callbacks are acceptable for act()
|
||||
act(() => {});
|
||||
// $ExpectError
|
||||
act(async () => {});
|
||||
// $ExpectError
|
||||
act(() => null);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user