Skip to content

Commit aea68eb

Browse files
authored
Merge pull request scratchfoundation#774 from paulkaplan/react-16
Update to react 16!
2 parents 59f2697 + 8ded00f commit aea68eb

File tree

5 files changed

+41
-20
lines changed

5 files changed

+41
-20
lines changed

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@ node_js:
1111
cache:
1212
directories:
1313
- node_modules
14-
env:
15-
global:
16-
- NODE_ENV=production
1714
install:
18-
- npm --production=false install
19-
- npm --production=false update
15+
- npm install
16+
- npm update
2017
before_deploy:
2118
- npm --no-git-tag-version version 0.1.0-prerelease.$(date +%Y%m%d%H%M%S)
2219
- git config --global user.email $(git log --pretty=format:"%ae" -n1)
@@ -39,4 +36,3 @@ deploy:
3936
skip_cleanup: true
4037
email: $NPM_EMAIL
4138
api_key: $NPM_TOKEN
42-

package.json

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"i18n:msgs": "node ./scripts/generate-locale-messages.js",
1111
"i18n:src": "babel src > tmp.js && rimraf tmp.js && ./scripts/build-i18n-source.js ./translations/messages/ ./translations/",
1212
"start": "npm run i18n:msgs && webpack-dev-server",
13-
"test": "npm run test:lint && npm run build && npm run test:unit && npm run test:integration",
13+
"test": "npm run test:lint && npm run test:unit && NODE_ENV=production npm run build && npm run test:integration",
1414
"test:integration": "jest --runInBand test[\\\\/]integration",
1515
"test:lint": "eslint . --ext .js,.jsx",
1616
"test:unit": "jest test[\\\\/]unit",
@@ -24,8 +24,8 @@
2424
"url": "git+ssh://[email protected]/LLK/scratch-gui.git"
2525
},
2626
"peerDependencies": {
27-
"react": "^15.6.1",
28-
"react-dom": "^15.6.1"
27+
"react": "^16.0.0",
28+
"react-dom": "^16.0.0"
2929
},
3030
"devDependencies": {
3131
"autoprefixer": "^7.1.3",
@@ -43,7 +43,8 @@
4343
"classnames": "2.2.5",
4444
"copy-webpack-plugin": "^4.0.1",
4545
"css-loader": "^0.28.7",
46-
"enzyme": "^2.8.2",
46+
"enzyme": "^3.1.0",
47+
"enzyme-adapter-react-16": "1.0.1",
4748
"eslint": "^4.7.1",
4849
"eslint-config-scratch": "^5.0.0",
4950
"eslint-plugin-import": "^2.7.0",
@@ -65,18 +66,19 @@
6566
"postcss-loader": "^2.0.5",
6667
"postcss-simple-vars": "^4.0.0",
6768
"prop-types": "^15.5.10",
68-
"react": "15.6.1",
69-
"react-contextmenu": "2.7.0",
70-
"react-dom": "15.6.1",
69+
"raf": "^3.4.0",
70+
"react": "16.0.0",
71+
"react-contextmenu": "2.8.0",
72+
"react-dom": "16.0.0",
7173
"react-draggable": "3.0.3",
7274
"react-intl": "2.4.0",
7375
"react-intl-redux": "0.6.0",
74-
"react-modal": "2.3.1",
76+
"react-modal": "3.0.0",
7577
"react-redux": "5.0.6",
76-
"react-responsive": "1.3.4",
78+
"react-responsive": "2.0.0",
7779
"react-style-proptype": "3.0.0",
7880
"react-tabs": "2.1.0",
79-
"react-test-renderer": "^15.5.4",
81+
"react-test-renderer": "16.0.0",
8082
"redux": "3.7.0",
8183
"redux-mock-store": "^1.2.3",
8284
"redux-throttle": "0.1.1",
@@ -98,6 +100,10 @@
98100
"xhr": "2.4.0"
99101
},
100102
"jest": {
103+
"setupFiles": [
104+
"raf/polyfill",
105+
"<rootDir>/test/helpers/enzyme-setup.js"
106+
],
101107
"testPathIgnorePatterns": [
102108
"src/test.js"
103109
],

test/helpers/enzyme-setup.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Enzyme from 'enzyme';
2+
import Adapter from 'enzyme-adapter-react-16';
3+
4+
Enzyme.configure({adapter: new Adapter()});

test/unit/containers/sound-editor.test.jsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('Sound Editor Container', () => {
6363
store={store}
6464
/>
6565
);
66-
const component = wrapper.find(SoundEditorComponent);
66+
let component = wrapper.find(SoundEditorComponent);
6767
// Ensure rendering doesn't start playing any sounds
6868
expect(mockAudioBufferPlayer.instance.play.mock.calls).toEqual([]);
6969
expect(mockAudioBufferPlayer.instance.stop.mock.calls).toEqual([]);
@@ -73,9 +73,13 @@ describe('Sound Editor Container', () => {
7373

7474
// Mock the audio buffer player calling onUpdate
7575
mockAudioBufferPlayer.instance.onUpdate(0.5);
76+
wrapper.update();
77+
component = wrapper.find(SoundEditorComponent);
7678
expect(component.props().playhead).toEqual(0.5);
7779

7880
component.props().onStop();
81+
wrapper.update();
82+
component = wrapper.find(SoundEditorComponent);
7983
expect(mockAudioBufferPlayer.instance.stop).toHaveBeenCalled();
8084
expect(component.props().playhead).toEqual(null);
8185
});
@@ -87,13 +91,17 @@ describe('Sound Editor Container', () => {
8791
store={store}
8892
/>
8993
);
90-
const component = wrapper.find(SoundEditorComponent);
94+
let component = wrapper.find(SoundEditorComponent);
9195

9296
component.props().onActivateTrim();
97+
wrapper.update();
98+
component = wrapper.find(SoundEditorComponent);
9399
expect(component.props().trimStart).not.toEqual(null);
94100
expect(component.props().trimEnd).not.toEqual(null);
95101

96102
component.props().onActivateTrim();
103+
wrapper.update();
104+
component = wrapper.find(SoundEditorComponent);
97105
expect(vm.updateSoundBuffer).toHaveBeenCalled();
98106
expect(component.props().trimStart).toEqual(null);
99107
expect(component.props().trimEnd).toEqual(null);
@@ -223,7 +231,7 @@ describe('Sound Editor Container', () => {
223231
store={store}
224232
/>
225233
);
226-
const component = wrapper.find(SoundEditorComponent);
234+
let component = wrapper.find(SoundEditorComponent);
227235
// Undo and redo should be disabled initially
228236
expect(component.prop('canUndo')).toEqual(false);
229237
expect(component.prop('canRedo')).toEqual(false);
@@ -232,27 +240,34 @@ describe('Sound Editor Container', () => {
232240
component.props().onActivateTrim(); // Activate trimming
233241
component.props().onActivateTrim(); // Submit new samples by calling again
234242
wrapper.update();
243+
component = wrapper.find(SoundEditorComponent);
235244
expect(component.prop('canUndo')).toEqual(true);
236245
expect(component.prop('canRedo')).toEqual(false);
237246

238247
// Undoing should make it possible to redo and not possible to undo again
239248
component.props().onUndo();
240249
wrapper.update();
250+
component = wrapper.find(SoundEditorComponent);
241251
expect(component.prop('canUndo')).toEqual(false);
242252
expect(component.prop('canRedo')).toEqual(true);
243253

244254
// Redoing should make it possible to undo and not possible to redo again
245255
component.props().onRedo();
246256
wrapper.update();
257+
component = wrapper.find(SoundEditorComponent);
247258
expect(component.prop('canUndo')).toEqual(true);
248259
expect(component.prop('canRedo')).toEqual(false);
249260

250261
// New submission should clear the redo stack
251262
component.props().onUndo(); // Undo to go back to a state where redo is enabled
252263
wrapper.update();
264+
component = wrapper.find(SoundEditorComponent);
253265
expect(component.prop('canRedo')).toEqual(true);
254266
component.props().onActivateTrim(); // Activate trimming
255267
component.props().onActivateTrim(); // Submit new samples by calling again
268+
269+
wrapper.update();
270+
component = wrapper.find(SoundEditorComponent);
256271
expect(component.prop('canRedo')).toEqual(false);
257272
});
258273
});

test/unit/util/project-loader-hoc.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('ProjectLoaderHOC', () => {
4545
const before = mounted.find('div').text();
4646
ProjectLoader.load = jest.fn((id, cb) => cb(null, id));
4747
window.location.hash = `#winning`;
48-
mounted.node.updateProject();
48+
mounted.instance().updateProject();
4949
expect(mounted.find('div').text()).not.toEqual(before);
5050
});
5151
});

0 commit comments

Comments
 (0)