Skip to content

Commit

Permalink
Convert tests to use react-testing-library instead of Enzyme (reduxjs…
Browse files Browse the repository at this point in the history
…#998)

* Update React to 16.4.2

* Restore other test changes from 5.1.0-test commit

* Fix tests that fail due to use of a string ref

* Disable <StrictMode> tests for now

* Add react-testing-library

* Convert Provider tests to RTL

* Convert Connect tests to RTL

* Remove uses of Enzyme and getTestDeps

* Remove Enzyme and react-test-renderer packages

* Fix a test lint error

* Disable lint warnings about componentWillReceiveProps
  • Loading branch information
markerikson authored and josepot committed Sep 21, 2018
1 parent 73691e5 commit 56ae947
Show file tree
Hide file tree
Showing 43 changed files with 1,215 additions and 26,189 deletions.
1,052 changes: 441 additions & 611 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 14 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-redux",
"version": "5.1.0-test.1",
"description": "Official React bindings for Redux",
"name": "react-redux-lean",
"version": "0.0.1",
"description": "Unofficial React bindings for Redux",
"keywords": [
"react",
"reactjs",
Expand All @@ -14,10 +14,10 @@
"redux"
],
"license": "MIT",
"author": "Dan Abramov <dan.abramov@me.com> (https://github.com/gaearon)",
"homepage": "https://github.com/reduxjs/react-redux",
"repository": "github:reduxjs/react-redux",
"bugs": "https://github.com/reduxjs/react-redux/issues",
"author": "Josep M Sobrepere <josep.sobrepere@me.com> (https://github.com/josepot)",
"homepage": "https://github.com/josepot/react-redux-lean",
"repository": "github:josepot/react-redux-lean",
"bugs": "https://github.com/josepot/react-redux-lean/issues",
"main": "./lib/index.js",
"module": "es/index.js",
"files": [
Expand All @@ -33,21 +33,20 @@
"build:umd:min": "cross-env BABEL_ENV=rollup NODE_ENV=production rollup -c -o dist/react-redux.min.js",
"build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min",
"clean": "rimraf lib dist es coverage",
"lint": "eslint src test/utils test/components test/getTestDeps.js",
"lint": "eslint src test/utils test/components",
"prepare": "npm run clean && npm run build",
"test": "node ./test/run-tests.js",
"coverage": "codecov"
},
"peerDependencies": {
"react": "^0.14.0 || ^15.0.0-0 || ^16.0.0-0",
"react": "^16.4.0-0",
"redux": "^2.0.0 || ^3.0.0 || ^4.0.0-0"
},
"dependencies": {
"hoist-non-react-statics": "^2.5.5",
"invariant": "^2.2.4",
"loose-envify": "^1.1.0",
"prop-types": "^15.6.1",
"react-lifecycles-compat": "^3.0.0"
"prop-types": "^15.6.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
Expand Down Expand Up @@ -81,18 +80,17 @@
"create-react-class": "^15.6.3",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"es3ify": "^0.2.0",
"eslint": "^4.19.1",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.9.1",
"glob": "^7.1.1",
"jest": "^23.4.1",
"jest-dom": "^1.12.0",
"npm-run": "^5.0.1",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-test-renderer": "^16.3.2",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-testing-library": "^5.0.0",
"redux": "^4.0.0",
"rimraf": "^2.6.2",
"rollup": "^0.61.1",
Expand Down
43 changes: 43 additions & 0 deletions src/Provider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import PropTypes from 'prop-types'
import {Component, createContext, createElement} from 'react';

const context = createContext({});

export const {Consumer} = context;
const {Provider} = context;

export default class ReduxProvider extends Component {
constructor(props) {
super(props);
const {store, isSSR} = props;
this.state = {state: store.getState(), dispatch: store.dispatch};

if (!isSSR) {
this.subscription = store.subscribe(() => {
this.setState({state: store.getState()});
});
}
}

componentWillUnmount() {
this.subscription && this.subscription();
}

render() {
return createElement(Provider, {value: this.state, children: this.props.children});
}
}

ReduxProvider.propTypes = {
children: PropTypes.element.isRequired,
isSSR: PropTypes.bool,
store: PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired
}),
};

ReduxProvider.defaultProps = {
isSSR: false,
};
60 changes: 0 additions & 60 deletions src/components/Provider.js

This file was deleted.

Loading

0 comments on commit 56ae947

Please sign in to comment.