Skip to content

Commit e5c266f

Browse files
committed
Finish porting examples
1 parent 110bf30 commit e5c266f

Some content is hidden

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

49 files changed

+80
-93
lines changed

examples/async/favicon.ico

-24.3 KB
Binary file not shown.

examples/async/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.1",
44
"private": true,
55
"devDependencies": {
6-
"react-scripts": "0.4.0",
6+
"react-scripts": "^0.4.0",
77
"redux-logger": "^2.6.1"
88
},
99
"dependencies": {
@@ -16,8 +16,7 @@
1616
"scripts": {
1717
"start": "react-scripts start",
1818
"build": "react-scripts build",
19-
"eject": "react-scripts eject",
20-
"test": "react-scripts test"
19+
"eject": "react-scripts eject"
2120
},
2221
"eslintConfig": {
2322
"extends": "./node_modules/react-scripts/config/eslint.js"

examples/buildAll.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,27 @@ var exampleDirs = fs.readdirSync(__dirname).filter((file) => {
1010
return fs.statSync(path.join(__dirname, file)).isDirectory()
1111
})
1212

13-
for (const dir of exampleDirs) {
14-
// declare opts in this scope to avoid https://github.com/joyent/node/issues/9158
15-
const opts = {
16-
cwd: path.join(__dirname, dir),
17-
stdio: 'inherit'
18-
}
13+
// Ordering is important here. `npm install` must come first.
14+
var cmdArgs = [
15+
{ cmd: 'npm', args: [ 'install' ] },
16+
{ cmd: 'webpack', args: [ 'index.js' ] }
17+
]
1918

20-
let result = {}
21-
if (process.platform === 'win32') {
22-
result = spawnSync('npm.cmd', [ 'install' ], opts)
23-
} else {
24-
result = spawnSync('npm', [ 'install' ], opts)
25-
}
26-
if (result.status !== 0) {
27-
throw new Error('Building examples exited with non-zero')
19+
for (const dir of exampleDirs) {
20+
for (const cmdArg of cmdArgs) {
21+
// declare opts in this scope to avoid https://github.com/joyent/node/issues/9158
22+
const opts = {
23+
cwd: path.join(__dirname, dir),
24+
stdio: 'inherit'
25+
}
26+
let result = {}
27+
if (process.platform === 'win32') {
28+
result = spawnSync(cmdArg.cmd + '.cmd', cmdArg.args, opts)
29+
} else {
30+
result = spawnSync(cmdArg.cmd, cmdArg.args, opts)
31+
}
32+
if (result.status !== 0) {
33+
throw new Error('Building examples exited with non-zero')
34+
}
2835
}
2936
}

examples/counter/favicon.ico

-24.3 KB
Binary file not shown.

examples/counter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"devDependencies": {
66
"enzyme": "^2.4.1",
77
"react-addons-test-utils": "^15.3.0",
8-
"react-scripts": "0.4.0"
8+
"react-scripts": "^0.4.0"
99
},
1010
"dependencies": {
1111
"react": "^15.3.0",

examples/counter/src/components/Counter.spec.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import expect from 'expect'
21
import React from 'react'
32
import { shallow } from 'enzyme'
43
import Counter from './Counter'
54

65
function setup(value = 0) {
76
const actions = {
8-
onIncrement: expect.createSpy(),
9-
onDecrement: expect.createSpy()
7+
onIncrement: jest.fn(),
8+
onDecrement: jest.fn()
109
}
1110
const component = shallow(
1211
<Counter value={value} {...actions} />
@@ -29,38 +28,38 @@ describe('Counter component', () => {
2928
it('first button should call onIncrement', () => {
3029
const { buttons, actions } = setup()
3130
buttons.at(0).simulate('click')
32-
expect(actions.onIncrement).toHaveBeenCalled()
31+
expect(actions.onIncrement).toBeCalled()
3332
})
3433

3534
it('second button should call onDecrement', () => {
3635
const { buttons, actions } = setup()
3736
buttons.at(1).simulate('click')
38-
expect(actions.onDecrement).toHaveBeenCalled()
37+
expect(actions.onDecrement).toBeCalled()
3938
})
4039

4140
it('third button should not call onIncrement if the counter is even', () => {
4241
const { buttons, actions } = setup(42)
4342
buttons.at(2).simulate('click')
44-
expect(actions.onIncrement).toNotHaveBeenCalled()
43+
expect(actions.onIncrement).not.toBeCalled()
4544
})
4645

4746
it('third button should call onIncrement if the counter is odd', () => {
4847
const { buttons, actions } = setup(43)
4948
buttons.at(2).simulate('click')
50-
expect(actions.onIncrement).toHaveBeenCalled()
49+
expect(actions.onIncrement).toBeCalled()
5150
})
5251

5352
it('third button should call onIncrement if the counter is odd and negative', () => {
5453
const { buttons, actions } = setup(-43)
5554
buttons.at(2).simulate('click')
56-
expect(actions.onIncrement).toHaveBeenCalled()
55+
expect(actions.onIncrement).toBeCalled()
5756
})
5857

5958
it('fourth button should call onIncrement in a second', (done) => {
6059
const { buttons, actions } = setup()
6160
buttons.at(3).simulate('click')
6261
setTimeout(() => {
63-
expect(actions.onIncrement).toHaveBeenCalled()
62+
expect(actions.onIncrement).toBeCalled()
6463
done()
6564
}, 1000)
6665
})

examples/counter/src/reducers/index.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import expect from 'expect'
21
import counter from './index'
32

43
describe('reducers', () => {

examples/real-world/favicon.ico

-24.3 KB
Binary file not shown.

examples/real-world/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.1",
44
"private": true,
55
"devDependencies": {
6-
"react-scripts": "0.4.0",
6+
"react-scripts": "^0.4.0",
77
"redux-devtools": "^3.3.1",
88
"redux-devtools-dock-monitor": "^1.1.1",
99
"redux-devtools-log-monitor": "^1.0.11",
@@ -23,8 +23,7 @@
2323
"scripts": {
2424
"start": "react-scripts start",
2525
"build": "react-scripts build",
26-
"eject": "react-scripts eject",
27-
"test": "react-scripts test"
26+
"eject": "react-scripts eject"
2827
},
2928
"eslintConfig": {
3029
"extends": "./node_modules/react-scripts/config/eslint.js"

examples/shopping-cart/favicon.ico

-24.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)