This commit is contained in:
John Reilly
2017-04-27 15:26:51 +01:00
parent c340b2e633
commit cff3ba9479
3 changed files with 32 additions and 2 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
// Type definitions for react-test-renderer 15.4
// Type definitions for react-test-renderer 15.5
// Project: https://facebook.github.io/react/
// Definitions by: Arvitaly <https://github.com/arvitaly>, Lochbrunner <https://github.com/lochbrunner>
// Definitions by: Arvitaly <https://github.com/arvitaly>, Lochbrunner <https://github.com/lochbrunner>, Lochbrunner <https://github.com/lochbrunner>, John Reilly <https://github.com/johnnyreilly/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
@@ -1,5 +1,6 @@
import React = require("react");
import { create } from "react-test-renderer";
import * as ReactTestUtils from './shallow';
const tree = create(React.createElement("div"), {
createNodeMock: (el: React.ReactElement<any>) => {
@@ -13,3 +14,10 @@ tree.props = {
};
tree.children = [tree];
tree.$$typeof = "t";
class TestComponent extends React.Component<{}, {}> { }
const component = React.createElement(TestComponent);
const shallowRenderer = ReactTestUtils.createRenderer();
shallowRenderer.render(component);
shallowRenderer.getRenderOutput();
+22
View File
@@ -0,0 +1,22 @@
import { ReactElement } from 'react';
export interface ShallowRenderer {
/**
* After `shallowRenderer.render()` has been called, returns shallowly rendered output.
*/
getRenderOutput<E extends ReactElement<any>>(): E;
/**
* After `shallowRenderer.render()` has been called, returns shallowly rendered output.
*/
getRenderOutput(): ReactElement<any>;
/**
* Similar to `ReactDOM.render` but it doesn't require DOM and only renders a single level deep.
*/
render(element: ReactElement<any>, context?: any): void;
unmount(): void;
}
/**
* Call this in your tests to create a shallow renderer.
*/
export function createRenderer(): ShallowRenderer;