Skip to content

Commit 01e9fc1

Browse files
markeriksonjosepot
authored andcommitted
Convert tests to use react-testing-library instead of Enzyme (reduxjs#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
1 parent 1939e6e commit 01e9fc1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1215
-26189
lines changed

package-lock.json

Lines changed: 441 additions & 611 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "react-redux",
3-
"version": "5.1.0-test.1",
4-
"description": "Official React bindings for Redux",
2+
"name": "react-redux-lean",
3+
"version": "0.0.1",
4+
"description": "Unofficial React bindings for Redux",
55
"keywords": [
66
"react",
77
"reactjs",
@@ -14,10 +14,10 @@
1414
"redux"
1515
],
1616
"license": "MIT",
17-
"author": "Dan Abramov <dan.abramov@me.com> (https://github.com/gaearon)",
18-
"homepage": "https://github.com/reduxjs/react-redux",
19-
"repository": "github:reduxjs/react-redux",
20-
"bugs": "https://github.com/reduxjs/react-redux/issues",
17+
"author": "Josep M Sobrepere <josep.sobrepere@me.com> (https://github.com/josepot)",
18+
"homepage": "https://github.com/josepot/react-redux-lean",
19+
"repository": "github:josepot/react-redux-lean",
20+
"bugs": "https://github.com/josepot/react-redux-lean/issues",
2121
"main": "./lib/index.js",
2222
"module": "es/index.js",
2323
"files": [
@@ -33,21 +33,20 @@
3333
"build:umd:min": "cross-env BABEL_ENV=rollup NODE_ENV=production rollup -c -o dist/react-redux.min.js",
3434
"build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min",
3535
"clean": "rimraf lib dist es coverage",
36-
"lint": "eslint src test/utils test/components test/getTestDeps.js",
36+
"lint": "eslint src test/utils test/components",
3737
"prepare": "npm run clean && npm run build",
3838
"test": "node ./test/run-tests.js",
3939
"coverage": "codecov"
4040
},
4141
"peerDependencies": {
42-
"react": "^0.14.0 || ^15.0.0-0 || ^16.0.0-0",
42+
"react": "^16.4.0-0",
4343
"redux": "^2.0.0 || ^3.0.0 || ^4.0.0-0"
4444
},
4545
"dependencies": {
4646
"hoist-non-react-statics": "^2.5.5",
4747
"invariant": "^2.2.4",
4848
"loose-envify": "^1.1.0",
49-
"prop-types": "^15.6.1",
50-
"react-lifecycles-compat": "^3.0.0"
49+
"prop-types": "^15.6.1"
5150
},
5251
"devDependencies": {
5352
"babel-cli": "^6.26.0",
@@ -81,18 +80,17 @@
8180
"create-react-class": "^15.6.3",
8281
"cross-env": "^5.2.0",
8382
"cross-spawn": "^6.0.5",
84-
"enzyme": "^3.3.0",
85-
"enzyme-adapter-react-16": "^1.1.1",
8683
"es3ify": "^0.2.0",
8784
"eslint": "^4.19.1",
8885
"eslint-plugin-import": "^2.12.0",
8986
"eslint-plugin-react": "^7.9.1",
9087
"glob": "^7.1.1",
9188
"jest": "^23.4.1",
89+
"jest-dom": "^1.12.0",
9290
"npm-run": "^5.0.1",
93-
"react": "^16.3.2",
94-
"react-dom": "^16.3.2",
95-
"react-test-renderer": "^16.3.2",
91+
"react": "^16.4.2",
92+
"react-dom": "^16.4.2",
93+
"react-testing-library": "^5.0.0",
9694
"redux": "^4.0.0",
9795
"rimraf": "^2.6.2",
9896
"rollup": "^0.61.1",

src/Provider.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import PropTypes from 'prop-types'
2+
import {Component, createContext, createElement} from 'react';
3+
4+
const context = createContext({});
5+
6+
export const {Consumer} = context;
7+
const {Provider} = context;
8+
9+
export default class ReduxProvider extends Component {
10+
constructor(props) {
11+
super(props);
12+
const {store, isSSR} = props;
13+
this.state = {state: store.getState(), dispatch: store.dispatch};
14+
15+
if (!isSSR) {
16+
this.subscription = store.subscribe(() => {
17+
this.setState({state: store.getState()});
18+
});
19+
}
20+
}
21+
22+
componentWillUnmount() {
23+
this.subscription && this.subscription();
24+
}
25+
26+
render() {
27+
return createElement(Provider, {value: this.state, children: this.props.children});
28+
}
29+
}
30+
31+
ReduxProvider.propTypes = {
32+
children: PropTypes.element.isRequired,
33+
isSSR: PropTypes.bool,
34+
store: PropTypes.shape({
35+
subscribe: PropTypes.func.isRequired,
36+
dispatch: PropTypes.func.isRequired,
37+
getState: PropTypes.func.isRequired
38+
}),
39+
};
40+
41+
ReduxProvider.defaultProps = {
42+
isSSR: false,
43+
};

src/components/Provider.js

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)