Open tapetersen opened 5 years ago
Ok the test fails and updating the jest environment fixes most of them but the last context based one I can't really get rid of. For what it's worth liform-react is compatible enough for our projects needs but I can understand you don't want to merge it completely without getting those tests to pass as well.
FAIL src/__tests__/createLiformSpec.spec.js
createLiform
✓ should render a form (49ms)
✕ can pass a context (11ms)
● createLiform › can pass a context
TypeError: Cannot read property 'fun' of undefined
at CustomString (src/__tests__/createLiformSpec.spec.js:46:27)
at processChild (node_modules/react-dom/cjs/react-dom-server.node.development.js:2888:14)
at resolve (node_modules/react-dom/cjs/react-dom-server.node.development.js:2812:5)
at ReactDOMServerRenderer.render (node_modules/react-dom/cjs/react-dom-server.node.development.js:3202:22)
at ReactDOMServerRenderer.read (node_modules/react-dom/cjs/react-dom-server.node.development.js:3161:29)
at Object.renderToStaticMarkup (node_modules/react-dom/cjs/react-dom-server.node.development.js:3661:27)
at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:902:42)
at render (node_modules/enzyme/build/render.js:41:23)
at Object.<anonymous> (src/__tests__/createLiformSpec.spec.js:68:38)
Having tried debugging it a bit it looks like props are completetly undefined for both the intial Liform Component in the test below and for CustomString in turn. I'm not sure if this is because of discrepancies with enzyme vs a real browser or a real incompatibility with newer react versions.
it("can pass a context", () => {
const CustomString = field => {
const { fun } = field.context;
fun();
return <input {...field.input} className="form-control" type="email" />;
};
const CustomWidget = props => {
return (
<Field
component={CustomString}
name={props.fieldName}
context={props.context}
/>
);
};
const myTheme = { ...DefaultTheme, string: CustomWidget };
const fun = jest.fn();
const Component = (
<FormFrame>
<Liform schema={schema} context={{ fun }} theme={myTheme} />
</FormFrame>
);
const wrapper = render(Component);
expect(fun).toHaveBeenCalled();
expect(wrapper.find("input").length).toEqual(1);
});
Update to allow newer version of react-redux and react-form since from what I can see it's compatible (have run the test suite) and keeping the versions low creates problems, in particular where react-redux < 6 can't really coexist with versions > 6.