MapStore2
MapStore2 copied to clipboard
Offer to upgrade tests to support a higher version of react-redux
Description
In our version of MapStore, we are currently using a newer version of react-redux
, i.e. 7.1.3
instead of 6.0.0
, because it has a much cleaner syntax.
However, this breaks tests, because of the render
-function from react-dom
, which is frequently being used like this:
// StandardAppComponent-test
const app = ReactDOM.render(<Provider store={store}><StandardAppComponent/></Provider>, document.getElementById("container"));
expect(app).toExist();
render
does not return anything for stateless components:
Render a React element into the DOM in the supplied container and return a reference to the component (or returns null for stateless components).
And apparently, by upgrading to react-redux 7.x
, some components become stateless.
A first step to enable you to upgrade to react-redux 7.x
and enable us to keep using it would be to rewrite such tests like this:
const container = document.getElementById("container");
expect(container.innerHTML).toNotExist();
ReactDOM.render(<Provider store={store}><StandardAppComponent/></Provider>, container, () => {
expect(container.innerHTML).toExist();
done();
});
Would you accept a pull request with these changes to the tests?
This does not break compatibility with your current react-redux
version and might also help with upgrading the tests once you reach
React 18 (where render
is deprecated entirely).
What kind of improvement you want to add? (check one with "x", remove the others)
- [x] Refactoring (no functional changes, no api changes)
Other useful information
This concerns the tests for
- StandardContainer
- StandardAppComponent
- StandardRouter
- ZoomButton
- ZoomToMaxExtentButton
- HomeComponent
- PluginsContainer
- PaginationToolbar
- MapViewerCmp
- PluginsUtils