Skip to content

Commit 71070be

Browse files
committed
steps 1-6 progress
1 parent 7cdb67c commit 71070be

File tree

16 files changed

+101
-50
lines changed

16 files changed

+101
-50
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ CodeRoad is an open-sourced interactive tutorial platform for the Atom Editor. L
3030

3131
##### Combine Reducers
3232

33-
Create modular, composable reducers.
33+
Create modular, composable reducers with `combineReducers`.

coderoad.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@
66
"pages": [
77
{
88
"title": "Combine Reducers",
9-
"description": "Create modular, composable reducers.",
9+
"description": "Create modular, composable reducers with `combineReducers`.",
1010
"tasks": [
1111
{
12-
"description": "import `combineReducers` from redux",
12+
"description": "create a new `const reducers` and set it equal to \"reducer\". Pass \"reducers\" into your store for now, instead of \"reducer\". We'll use combineReducers shortly, but let's not break the app yet.",
1313
"tests": [
1414
"06/01"
15-
],
16-
"hints": [
17-
"Try this: `import { combineReducers } from 'redux';`"
1815
]
1916
},
2017
{
21-
"description": "create a new `const reducers` and set it to \"reducer\". Pass \"reducers\" into your store for now, instead of \"reducer\". We'll use combineReducers shortly, but let's not break the app yet.",
18+
"description": "We're going to create more than one reducer. They can't all be called \"reducer\", so rename your original reducer \"pokemon\". Make sure to set reducers equal to the new name as well.",
2219
"tests": [
2320
"06/02"
2421
]
2522
},
2623
{
27-
"description": "We're going to create more than one reducer. They can't all be called \"reducer\", so rename your reducer 'pokemon'.",
24+
"description": "import `combineReducers` from redux",
2825
"tests": [
2926
"06/03"
27+
],
28+
"hints": [
29+
"Try this: `import { combineReducers } from 'redux';`"
3030
]
3131
},
3232
{

tutorial/01/02.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
describe('02 setup', () => {
2+
3+
it('should create an "index.html" file.', () => {
4+
expect(exists('index.html')).to.be.true;
5+
});
6+
7+
it('hasn\'t compiled the source. Run `npm start`', () => {
8+
expect(exists('dist/bundle.js')).to.be.true;
9+
});
10+
11+
});

tutorial/01/index.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Running `> npm run setup` will do the following:
1212

1313
You'll find this "setup" script located in your *package.json*.
1414

15+
1516
---
1617

1718
We'll be installing a lot of scripts from terminal. You may also want to consider installing the atom package ["platformio-ide-terminal"](https://github.com/platformio/platformio-atom-ide-terminal), which provides a terminal inside your editor.
@@ -38,7 +39,7 @@ We'll be installing a lot of scripts from terminal. You may also want to conside
3839
"test": "echo \"Error: no test specified\" && exit 1"
3940
},
4041
"dependencies": {
41-
"mocha-coderoad": "0.9.0"
42+
"mocha-coderoad": "0.9.3"
4243
},
4344
"devDependencies": {
4445
"babel-preset-es2015": "^6.9.0",
@@ -60,18 +61,46 @@ We'll be installing a lot of scripts from terminal. You may also want to conside
6061
}
6162
},
6263
"scripts": {
63-
"browserify": "browserify src/index.js --extension=.jsx -o dist/bundle.js -t [ babelify --presets [ es2015 react ] ]",
64+
"browserify": "browserify index.js --extension=.jsx -o dist/bundle.js -t [ babelify --presets [ es2015 react ] ]",
6465
"browsersync:reload": "browser-sync reload",
6566
"browsersync:start": "browser-sync start --server --files 'index.html dist/bundle.js'",
6667
"build": "npm run browserify",
6768
"reload": "npm run browserify && npm run browsersync:reload",
6869
"start": "concurrently --kill-others 'npm run build' 'npm run browsersync:start' 'npm run watch'",
6970
"test": "echo \"Error: no test specified\" && exit 1",
7071
"watch": "npm-watch",
71-
"setup": "npm install && mkdir -p dist && npm i -g concurrently browser-sync && npm start"
72+
"setup": "npm install && mkdir -p dist && npm i -g concurrently browser-sync "
7273
}
7374
}
7475
```
7576
))
7677

78+
+ Start the app by running `npm start`
79+
@test('01/02')
80+
@action(open('index.html'))
81+
@action(set(
82+
```
83+
<!DOCTYPE html>
84+
<html lang="en">
85+
<head>
86+
<meta charset="UTF-8">
87+
<title>Worst Pokemon</title>
88+
<link
89+
rel="stylesheet"
90+
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
91+
crossorigin="anonymous"
92+
/>
93+
</head>
94+
<body>
95+
<div id="app">
96+
<p>Check the console...</p>
97+
</div>
98+
99+
<script src="dist/bundle.js"></script>
100+
</body>
101+
</html>
102+
103+
```
104+
))
105+
77106
@onPageComplete('Continue to start working with Redux')

tutorial/06/01.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@ var expect = require('chai').expect;
22

33
/// load('index.js')
44

5-
describe('01 combineReducers', () => {
5+
describe('01 reducers', () => {
66

7-
it('should be loaded', () => {
8-
expect(combineReducers).to.be.defined;
7+
it('doesn\'t exist', () => {
8+
expect(reducers).to.be.defined;
9+
});
10+
11+
it('should be set to "reducer"', () => {
12+
// test must be support future state of reducers
13+
// reducer will be renamed "pokemon", and then
14+
// use combineReducers, which will be hard to track
15+
console.log(reducer);
16+
if (reducer) {
17+
expect(reducers).to.equal(reducer);
18+
} else {
19+
expect(true).to.be.true;
20+
}
921
});
1022

1123
});

tutorial/06/02.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
describe('02 reducers', () => {
1+
describe('02 reducer', () => {
22

3-
it('doesn\'t exist', () => {
4-
expect(reducers).to.be.defined;
5-
});
6-
7-
it('should be set to "reducer"', () => {
8-
if (process.env.TASK_POSITION === '2') {
9-
expect(reducers).to.equal(reducer);
10-
}
3+
it('should be renamed "pokemon"', () => {
4+
expect(reducer).not.to.be.defined;
5+
expect(pokemon).to.be.defined;
116
});
127

138
});

tutorial/06/03.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
describe('03 reducer', () => {
1+
describe('03 combineReducers', () => {
22

3-
it('should be renamed "pokemon"', () => {
4-
expect(reducer).not.to.be.defined;
5-
expect(pokemon).to.be.defined;
3+
it('should be loaded', () => {
4+
expect(combineReducers).to.be.defined;
65
});
76

87
});

tutorial/06/04.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
describe('04 reducers', () => {
22

3-
it('should be a new const', () => {
4-
expect(reducers).to.be.defined;
5-
});
6-
73
it('should call "combineReducers" with { pokemon }', () => {
8-
// expect(reducers)
4+
const regex = /pokemon/;
5+
const string = reducers.toString();
6+
expect(string).to.match(regex);
97
});
108

119
});

tutorial/06/07.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe('06 "pokemon" reducer', () => {
1+
describe('07 "pokemon" reducer', () => {
22

33
it('should have a default state of "defaultPokemon"', () => {
44
expect(pokemon(null, { type: 'ANY' })).to.have.length(3);

tutorial/06/08.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
describe('07 "pokemon" reducer', () => {
1+
describe('08 "pokemon" reducer', () => {
22

3-
it('should no longer call "state"', () => {
3+
it('should reference "pokemon", not "state"', () => {
44
const regex = /state/;
55
const string = pokemon.toString();
66
expect(string).not.to.match(regex);
77
});
88

9-
it('should return the correct state', () => {
10-
expect(pokemon(null, { type: 'VOTE_UP', payload: { id: 2} })[1].votes).be(1);
11-
});
12-
139
});

tutorial/06/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
## Combine Reducers
2-
Create modular, composable reducers.
2+
Create modular, composable reducers with `combineReducers`.
33

44

55

6-
+ import `combineReducers` from redux
6+
+ create a new `const reducers` and set it equal to "reducer". Pass "reducers" into your store for now, instead of "reducer". We'll use combineReducers shortly, but let's not break the app yet.
77
@test('06/01')
8-
@hint('Try this: `import { combineReducers } from 'redux';`')
98

10-
+ create a new `const reducers` and set it to "reducer". Pass "reducers" into your store for now, instead of "reducer". We'll use combineReducers shortly, but let's not break the app yet.
9+
+ We're going to create more than one reducer. They can't all be called "reducer", so rename your original reducer "pokemon". Make sure to set reducers equal to the new name as well.
1110
@test('06/02')
1211

13-
+ We're going to create more than one reducer. They can't all be called "reducer", so rename your reducer "pokemon".
12+
+ import `combineReducers` from redux
1413
@test('06/03')
14+
@hint('Try this: `import { combineReducers } from 'redux';`')
1515

16-
+ combineReducers(), and pass in your reducer ({ pokemon })
16+
+ combineReducers(), and pass in your reducer ({ pokemon })
1717
@test('06/04')
1818

1919
+ create a "defaultPokemon" state

tutorial/07/03.js

Whitespace-only changes.

tutorial/07/04.js

Whitespace-only changes.

tutorial/07/05.js

Whitespace-only changes.

tutorial/09/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,14 @@ Using thunks for async actions.
99

1010
+ add thunk to applyMiddleware. The logger should always go last
1111
@test('09/03')
12+
13+
+ change the voteUp action creator to return a thunk with the param of "dispatch"
14+
@test('09/04')
15+
16+
+ voteUp should dispatch VOTE_UP
17+
@test('09/05')
18+
19+
+ voteUp should dispatch sortByPopularity after each vote
20+
@test('09/06')
21+
22+
@onPageComplete('')

tutorial/tutorial.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
A [CodeRoad](https://coderoad.github.io) tutorial for learning Redux.
44

5-
<!-- @import('01') -->
6-
<!-- @import('02') -->
7-
<!-- @import('03') -->
8-
<!-- @import('04') -->
9-
<!-- @import('05') -->
5+
@import('01')
6+
@import('02')
7+
@import('03')
8+
@import('04')
9+
@import('05')
1010
@import('06')
1111
<!-- @import('07') -->
1212
<!-- @import('08') -->

0 commit comments

Comments
 (0)