Skip to content

Commit 0dbda73

Browse files
Merge branch 'release/1.1.0'
2 parents 293bbf0 + 30a7591 commit 0dbda73

7 files changed

+47
-33
lines changed

.travis.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ env:
99
- REACT_VERSION=0.13
1010
- REACT_VERSION=0.14
1111
- REACT_VERSION=15
12-
- REACT_VERSION=*
13-
before_install:
14-
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then npm install -g [email protected] ; elif [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g [email protected] ;; 2.*) npm install -g npm@2 ;; esac ; fi'
15-
- 'if [ "${TRAVIS_NODE_VERSION%${TRAVIS_NODE_VERSION#[0-9]}}" = "0" ] || [ "${TRAVIS_NODE_VERSION:0:4}" = "iojs" ]; then npm install -g [email protected] ; elif [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi'
16-
install:
17-
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then nvm install 0.8 && npm install -g [email protected] && npm install -g [email protected] && npm install -g npm@2 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;'
12+
- REACT_VERSION=16
1813
before_script:
1914
- ./install-dependencies.sh || echo "ignoring errors during setup"
2015
script:

install-dependencies.sh

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
#!/bin/bash
22
set -ev
33

4-
echo "installing React $REACT_VERSION"
4+
REACT_VERSION_NORMALIZED=$REACT_VERSION
5+
if [ "${REACT_VERSION:0:2}" = "0." ]; then
6+
REACT_VERSION_NORMALIZED=${REACT_VERSION:2}
7+
fi
8+
9+
echo "installing React $REACT_VERSION ($REACT_VERSION_NORMALIZED)"
510
echo "Travis Node Version $TRAVIS_NODE_VERSION"
611
node --version
712
npm --version
813

9-
npm uninstall --no-save react react-dom react-addons-test-utils react-test-renderer
10-
rm -rf node_modules/.bin/npm node_modules/.bin/npm.cmd node_modules/react node_modules/react-dom node_modules/react-addons-test-utils node_modules/react-test-renderer
14+
npm uninstall --no-save react react-dom react-addons-test-utils react-test-renderer enzyme-adapter-react-16
15+
rm -rf node_modules/.bin/npm node_modules/.bin/npm.cmd node_modules/react node_modules/react-dom node_modules/react-addons-test-utils node_modules/react-test-renderer node_modules/enzyme-adapter-react-16
1116
npm prune
1217

13-
npm install
14-
1518
# Conditionally install dependencies per https://github.com/airbnb/enzyme#installation
16-
if [ "${REACT_VERSION:0:2}" = "0." ]; then
17-
npm install --no-save react@$REACT_VERSION react-dom@$REACT_VERSION react-addons-test-utils@$REACT_VERSION
18-
else
19-
npm install --no-save react@$REACT_VERSION react-dom@$REACT_VERSION react-test-renderer@$REACT_VERSION
19+
if [ "${REACT_VERSION_NORMALIZED}" = "13" ]; then
20+
npm install --no-save react@$REACT_VERSION enzyme-adapter-react-$REACT_VERSION_NORMALIZED
21+
elif [ "${REACT_VERSION_NORMALIZED}" = "14" ]; then
22+
npm install --no-save react@$REACT_VERSION react-dom@$REACT_VERSION react-addons-test-utils@$REACT_VERSION enzyme-adapter-react-$REACT_VERSION_NORMALIZED
23+
elif [ "${REACT_VERSION_NORMALIZED}" = "15" ]; then
24+
npm install --no-save react@$REACT_VERSION react-dom@$REACT_VERSION react-test-renderer@$REACT_VERSION enzyme-adapter-react-$REACT_VERSION_NORMALIZED
25+
else # React 16+
26+
npm install --no-save react@$REACT_VERSION react-dom@$REACT_VERSION enzyme-adapter-react-$REACT_VERSION_NORMALIZED
2027
fi
2128

2229
npm ls --depth=0

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-component-update",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"description": "Extends the native React Component to streamline updates",
55
"main": "lib/index.js",
66
"scripts": {
@@ -32,7 +32,8 @@
3232
"codecov": "^2.3.0",
3333
"create-react-class": "^15.6.0",
3434
"dirty-chai": "^2.0.0",
35-
"enzyme": "^2.8.2",
35+
"enzyme": "^3.1.0",
36+
"enzyme-adapter-react-16": "^1.0.1",
3637
"eslint": "^3.19.0",
3738
"eslint-config-airbnb": "^15.0.1",
3839
"eslint-plugin-import": "^2.3.0",
@@ -42,7 +43,6 @@
4243
"lodash.uniqueid": "^4.0.1",
4344
"publish-please": "^2.3.1",
4445
"react": "*",
45-
"react-addons-test-utils": "*",
4646
"react-dom": "*",
4747
"react-test-renderer": "*",
4848
"rimraf": "^2.6.1",
@@ -55,6 +55,7 @@
5555
"jest": {
5656
"coverageDirectory": "./coverage/",
5757
"collectCoverage": true,
58+
"setupTestFrameworkScriptFile": "<rootDir>/test-setup.js",
5859
"testMatch": [
5960
"**/src/*.spec.js?(x)"
6061
]

src/component.spec.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('Component extension', () => {
5656
});
5757

5858
it('runs on mount with "this" context of component', () => {
59-
expect(callbackWill.firstCall).to.have.been.calledOn(component.getNode());
59+
expect(callbackWill.firstCall).to.have.been.calledOn(component.instance());
6060
});
6161

6262
it('runs on mount before render()', () => {
@@ -80,7 +80,7 @@ describe('Component extension', () => {
8080

8181
it('runs on props update with "this" context of component', () => {
8282
component.setProps(getUniqueProps());
83-
expect(callbackWill.secondCall).to.have.been.calledOn(component.getNode());
83+
expect(callbackWill.secondCall).to.have.been.calledOn(component.instance());
8484
});
8585

8686
it('runs on props update before render()', () => {
@@ -108,7 +108,7 @@ describe('Component extension', () => {
108108
});
109109

110110
it('runs on mount with "this" context of component', () => {
111-
expect(callbackDid.firstCall).to.have.been.calledOn(component.getNode());
111+
expect(callbackDid.firstCall).to.have.been.calledOn(component.instance());
112112
});
113113

114114
it('runs after render()', () => {
@@ -139,7 +139,7 @@ describe('Component extension', () => {
139139

140140
it('runs on props update with "this" context of component', () => {
141141
component.setProps(getUniqueProps());
142-
expect(callbackDid.secondCall).to.have.been.calledOn(component.getNode());
142+
expect(callbackDid.secondCall).to.have.been.calledOn(component.instance());
143143
});
144144

145145
it('runs on state update', () => {
@@ -166,7 +166,7 @@ describe('Component extension', () => {
166166

167167
it('runs on state update with "this" context of component', () => {
168168
component.setState(getUniqueState());
169-
expect(callbackDid.secondCall).to.have.been.calledOn(component.getNode());
169+
expect(callbackDid.secondCall).to.have.been.calledOn(component.instance());
170170
});
171171

172172
it('runs on props update before render()', () => {

src/pureComponent.spec.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ descriptor('PureComponent extension', () => {
5959
});
6060

6161
it('runs on mount with "this" context of component', () => {
62-
expect(callbackWill.firstCall).to.have.been.calledOn(component.getNode());
62+
expect(callbackWill.firstCall).to.have.been.calledOn(component.instance());
6363
});
6464

6565
it('runs on mount before render()', () => {
@@ -83,7 +83,7 @@ descriptor('PureComponent extension', () => {
8383

8484
it('runs on props update with "this" context of component', () => {
8585
component.setProps(getUniqueProps());
86-
expect(callbackWill.secondCall).to.have.been.calledOn(component.getNode());
86+
expect(callbackWill.secondCall).to.have.been.calledOn(component.instance());
8787
});
8888

8989
it('runs on props update before render()', () => {
@@ -111,7 +111,7 @@ descriptor('PureComponent extension', () => {
111111
});
112112

113113
it('runs on mount with "this" context of component', () => {
114-
expect(callbackDid.firstCall).to.have.been.calledOn(component.getNode());
114+
expect(callbackDid.firstCall).to.have.been.calledOn(component.instance());
115115
});
116116

117117
it('runs after render()', () => {
@@ -137,7 +137,7 @@ descriptor('PureComponent extension', () => {
137137

138138
it('runs on props update with "this" context of component', () => {
139139
component.setProps(getUniqueProps());
140-
expect(callbackDid.secondCall).to.have.been.calledOn(component.getNode());
140+
expect(callbackDid.secondCall).to.have.been.calledOn(component.instance());
141141
});
142142

143143
it('runs on state update', () => {
@@ -159,7 +159,7 @@ descriptor('PureComponent extension', () => {
159159

160160
it('runs on state update with "this" context of component', () => {
161161
component.setState(getUniqueState());
162-
expect(callbackDid.secondCall).to.have.been.calledOn(component.getNode());
162+
expect(callbackDid.secondCall).to.have.been.calledOn(component.instance());
163163
});
164164

165165
it('runs on props update before render()', () => {

src/withEvents.spec.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('withEvents extension', () => {
5252
});
5353

5454
it('runs on mount with "this" context of component', () => {
55-
expect(callbackWill.firstCall).to.have.been.calledOn(component.getNode());
55+
expect(callbackWill.firstCall).to.have.been.calledOn(component.instance());
5656
});
5757

5858
it('runs on mount before render()', () => {
@@ -76,7 +76,7 @@ describe('withEvents extension', () => {
7676

7777
it('runs on props update with "this" context of component', () => {
7878
component.setProps(getUniqueProps());
79-
expect(callbackWill.secondCall).to.have.been.calledOn(component.getNode());
79+
expect(callbackWill.secondCall).to.have.been.calledOn(component.instance());
8080
});
8181

8282
it('runs on props update before render()', () => {
@@ -104,7 +104,7 @@ describe('withEvents extension', () => {
104104
});
105105

106106
it('runs on mount with "this" context of component', () => {
107-
expect(callbackDid.firstCall).to.have.been.calledOn(component.getNode());
107+
expect(callbackDid.firstCall).to.have.been.calledOn(component.instance());
108108
});
109109

110110
it('runs after render()', () => {
@@ -130,7 +130,7 @@ describe('withEvents extension', () => {
130130

131131
it('runs on props update with "this" context of component', () => {
132132
component.setProps(getUniqueProps());
133-
expect(callbackDid.secondCall).to.have.been.calledOn(component.getNode());
133+
expect(callbackDid.secondCall).to.have.been.calledOn(component.instance());
134134
});
135135

136136
it('runs on state update', () => {
@@ -152,7 +152,7 @@ describe('withEvents extension', () => {
152152

153153
it('runs on state update with "this" context of component', () => {
154154
component.setState(getUniqueState());
155-
expect(callbackDid.secondCall).to.have.been.calledOn(component.getNode());
155+
expect(callbackDid.secondCall).to.have.been.calledOn(component.instance());
156156
});
157157

158158
it('runs on props update before render()', () => {

test-setup.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* eslint-disable global-require, import/no-extraneous-dependencies, import/no-unresolved */
2+
const configure = require('enzyme').configure;
3+
const reactVersion = require('react').version;
4+
5+
const [majorReactVersion, minorReactVersion] = reactVersion.split('.');
6+
const adapterVersion = (majorReactVersion !== '0') ? majorReactVersion : minorReactVersion;
7+
8+
// eslint-disable-next-line import/no-dynamic-require
9+
const Adapter = require(`enzyme-adapter-react-${adapterVersion}`);
10+
11+
configure({ adapter: new Adapter() });

0 commit comments

Comments
 (0)