2015-10-11 20:07:09 +03:00
|
|
|
import React from 'react';
|
2018-02-20 23:01:21 +03:00
|
|
|
import TestUtils from 'react-dom/test-utils';
|
2015-09-05 22:34:16 +03:00
|
|
|
|
2015-11-21 16:26:17 +03:00
|
|
|
export default {
|
2017-01-26 20:05:32 +03:00
|
|
|
renderComponent(Component, props = {}, state = {}) {
|
2015-10-23 11:11:40 +03:00
|
|
|
const component = TestUtils.renderIntoDocument(<Component {...props} />);
|
2015-09-05 22:34:16 +03:00
|
|
|
if (state !== {}) { component.setState(state); }
|
|
|
|
return component;
|
|
|
|
},
|
|
|
|
|
2017-01-26 20:05:32 +03:00
|
|
|
shallowRenderComponent(component, props, ...children) {
|
2015-10-23 11:11:40 +03:00
|
|
|
const shallowRenderer = TestUtils.createRenderer();
|
2017-01-28 15:16:31 +03:00
|
|
|
shallowRenderer.render(React.createElement(component, props, children.length > 1
|
2017-01-26 20:05:32 +03:00
|
|
|
? children
|
|
|
|
: children[0],
|
2017-01-28 15:16:31 +03:00
|
|
|
));
|
|
|
|
return shallowRenderer.getRenderOutput();
|
2017-01-26 20:05:32 +03:00
|
|
|
},
|
2015-09-05 22:34:16 +03:00
|
|
|
};
|