2018-10-06 23:42:52 +02:00
|
|
|
// @flow
|
|
|
|
|
import * as React from 'react';
|
|
|
|
|
import ShallowRenderer from 'react-test-renderer/shallow'; // eslint-disable-line import/no-extraneous-dependencies
|
2020-05-19 16:18:05 +02:00
|
|
|
import { throwRemovedFunctionError } from './helpers/errors';
|
2018-10-06 23:42:52 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Renders test component shallowly using react-test-renderer/shallow
|
|
|
|
|
*/
|
2020-03-18 13:03:21 +01:00
|
|
|
export function shallowInternal(
|
2018-11-28 12:49:15 +01:00
|
|
|
instance: ReactTestInstance | React.Element<any>
|
2018-10-06 23:42:52 +02:00
|
|
|
) {
|
|
|
|
|
const renderer = new ShallowRenderer();
|
2018-10-16 18:00:54 +02:00
|
|
|
|
|
|
|
|
renderer.render(React.createElement(instance.type, instance.props));
|
2018-10-06 23:42:52 +02:00
|
|
|
|
|
|
|
|
return {
|
2018-10-16 18:00:54 +02:00
|
|
|
output: renderer.getRenderOutput(),
|
2018-10-06 23:42:52 +02:00
|
|
|
};
|
|
|
|
|
}
|
2020-03-18 13:03:21 +01:00
|
|
|
|
2020-05-19 16:18:05 +02:00
|
|
|
export default function shallow(_: ReactTestInstance | React.Element<any>) {
|
|
|
|
|
throwRemovedFunctionError(
|
|
|
|
|
'shallow',
|
|
|
|
|
'migration-v2#removed-global-shallow-function'
|
|
|
|
|
);
|
2020-03-18 13:03:21 +01:00
|
|
|
}
|