Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit631786f

Browse files
committed
update for mocha 0.10
1 parentc4d46db commit631786f

34 files changed

+176
-107
lines changed

‎README.md‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
A[CodeRoad](https://coderoad.github.io) tutorial for learning Redux.
44

55
<!-- @import('01')-->
6-
<!-- @import('02')-->
76
<!-- @import('03')-->
87
<!-- @import('04')-->
98
<!-- @import('05')-->
109
<!-- @import('06')-->
10+
<!-- @import('07')-->
1111
<!-- @import('08')-->
1212
<!-- @import('09')-->
13+
<!-- @import('10')-->
1314

1415

1516
##CodeRoad
@@ -28,6 +29,10 @@ CodeRoad is an open-sourced interactive tutorial platform for the Atom Editor. L
2829

2930
##Outline
3031

31-
#####File Structure
32+
#####The Store
3233

33-
Refactor your project into different files.
34+
The "single source of truth".
35+
36+
```js
37+
conststore=createStore(reducer, initialState);
38+
```

‎coderoad.json‎

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,77 @@
11
{
22
"info": {
33
"title":"CodeRoad Redux JS Tutorial",
4-
"description":"A [CodeRoad](https://coderoad.github.io) tutorial for learning Redux.\n\n<!-- @import('01') -->\n<!-- @import('02') -->\n<!-- @import('03') -->\n<!-- @import('04') -->\n<!-- @import('05') -->\n<!-- @import('06') -->\n<!-- @import('08') -->\n<!-- @import('09') -->"
4+
"description":"A [CodeRoad](https://coderoad.github.io) tutorial for learning Redux.\n\n<!-- @import('01') -->\n<!-- @import('03') -->\n<!-- @import('04') -->\n<!-- @import('05') -->\n<!-- @import('06') -->\n<!-- @import('07') -->\n<!-- @import('08') -->\n<!-- @import('09') -->\n<!-- @import('10') -->"
55
},
66
"pages": [
77
{
8-
"title":"File Structure",
9-
"description":"Refactor your project into different files.",
8+
"title":"The Store",
9+
"description":"The\"single source of truth\".\n\n```js\nconst store = createStore(reducer, initialState);\n```",
1010
"tasks": [
1111
{
12-
"description":"create a folder in your base directory called\"pokemon\" and add a file inside called\"index.js\"",
12+
"description":"install Redux.",
13+
"hints": [
14+
"Run `npm install --save redux`."
15+
],
16+
"actions": [
17+
"open('index.js')"
18+
],
1319
"tests": [
14-
"07/01"
20+
"02/01"
1521
]
1622
},
1723
{
18-
"description":"take your `VOTE_UP` action typefrom\"index.js\" and put it in\"pokemon/index.js\"",
19-
"tests": [
20-
"07/02"
24+
"description":"import `createStore`fromthe redux module.",
25+
"hints": [
26+
"Add `import { createStore } from 'redux';`"
2127
],
28+
"tests": [
29+
"02/02"
30+
]
31+
},
32+
{
33+
"description":"create your first store and call it `store`. Use a simple\"reducer\" function for now, let's say `state => state`.",
2234
"hints": [
23-
"\"pokemon/index.js\" should have `const VOTE_UP = 'VOTE_UP';`"
35+
"declare your store, `const store`",
36+
"call store with a simple reducer, `const store = createStore(state => state)`"
37+
],
38+
"tests": [
39+
"02/03"
2440
]
2541
},
2642
{
27-
"description":"take your`voteUp` action creator from\"index.js\"andput it in\"pokemon/index.js\". Export it as a [\"named\" export](https://developer.mozilla.org/en/docs/web/javascript/reference/statements/export).",
43+
"description":"log yourstore to the consoleandhave a look.",
2844
"tests": [
29-
"07/03"
45+
"02/04"
3046
],
3147
"hints": [
32-
"move `voteUp` into\"pokemon/index.js\"",
33-
"\"pokemon/index.js\" should have `const voteUp = id => ({ type: VOTE_UP, payload: { id } });`"
48+
"console.log(store)"
3449
]
3550
},
3651
{
37-
"description":"take your `pokemon` reducer from\"index.js\" and put it in\"pokemon/index.js\". Exportthereducer as a\"default\" export",
52+
"description":"log `store.getState()` totheconsole",
3853
"tests": [
39-
"07/04"
54+
"02/05"
55+
],
56+
"hints": [
57+
"console.log(store.getState())"
4058
]
4159
},
4260
{
43-
"description":"in your\"index.js\" file, import theaction creatorsandreducerinone line of code.",
61+
"description":"move the initial state to thetop of the file,andpass itinas a second param your `createStore`",
4462
"tests": [
45-
"07/05"
63+
"02/06"
4664
],
4765
"hints": [
48-
"Try this: `import { default as pokemon, voteUp } from './pokemon';`"
66+
"Move `initialState` above your `store`",
67+
"Pass in `initialState` as a second param to `createStore`"
68+
],
69+
"actions": [
70+
"insert('const initialState = {\n pokemon: [{\n id: 1,\n name: 'Luvdisc',\n description: 'This heart-shaped POKéMON earned its name by swimming after loving couples it spotted in the ocean’s waves.',\n votes: 3\n }, {\n id: 2,\n name: 'Trubbish',\n description: 'Wanting more garbage, they follow people who litter. They always belch poison gas.',\n votes: 2\n }, {\n id: 3,\n name: 'Stunfisk',\n description: 'Its skin is very hard, so it is unhurt even if stepped on by sumo wrestlers. It smiles when transmitting electricity.',\n votes: 0\n }]\n };\n')"
4971
]
5072
}
5173
],
52-
"onPageComplete":""
74+
"onPageComplete":"As you can see, the store is just an object with various methods like\"dispatch\" and\"getState\". Let's see what these methods do in the next step."
5375
}
5476
]
5577
}

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
},
1515
"config": {
1616
"dir":"tutorial",
17-
"testSuffix":".js",
17+
"edit":true,
1818
"language":"JS",
1919
"runner":"mocha-coderoad",
20-
"edit":true
20+
"testSuffix":".js"
2121
},
2222
"dependencies": {
2323
"mocha-coderoad":"0.9.1"

‎tutorial/01/01.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
varexpect=require('chai').expect;
1+
constexpect=require('chai').expect;
22

33
describe('01 setup',()=>{
44

‎tutorial/02/01.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
varchai=require('chai');
2-
varspies=require('chai-spies');
3-
varexpect=chai.expect;
1+
constchai=require('chai');
2+
constspies=require('chai-spies');
3+
constexpect=chai.expect;
44
chai.use(spies);
55

6-
varspy=chai.spy.on(console,'log');
6+
letspy=chai.spy.on(console,'log');
77

8-
/// load('index.js')
8+
constindex=require('BASE/index.js');
99

1010
describe('01 Redux',()=>{
1111

‎tutorial/02/02.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
describe('02 createStore',()=>{
22

3+
constcreateStore=index.__get__('createStore');
4+
35
it('isn\'t imported. `import { createStore } from "redux";`',()=>{
46
expect(createStore).to.be.defined;
57
});

‎tutorial/02/03.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
describe('03 store',()=>{
22

3+
conststore=index.__get__('store');
4+
35
it('isn\'t defined. `const store`',()=>{
46
expect(store).to.be.defined;
57
});

‎tutorial/02/06.js‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ describe('06 log initialState', () => {
33
it('isn\'t logged to the console.',()=>{
44

55
constinitialState={
6-
pokemon:[{
7-
id:1,
8-
name:'Luvdisc',
9-
description:'This heart-shaped POKéMON earned its name by swimming after loving couples it spotted in the ocean’s waves.',
10-
votes:3
11-
},{
12-
id:2,
13-
name:'Trubbish',
14-
description:'Wanting more garbage, they follow people who litter. They always belch poison gas.',
15-
votes:2
16-
},{
17-
id:3,
18-
name:'Stunfisk',
19-
description:'Its skin is very hard, so it is unhurt even if stepped on by sumo wrestlers. It smiles when transmitting electricity.',
20-
votes:0
21-
}]
22-
};
6+
pokemon:[{
7+
id:1,
8+
name:'Luvdisc',
9+
description:'This heart-shaped POKéMON earned its name by swimming after loving couples it spotted in the ocean’s waves.',
10+
votes:3
11+
},{
12+
id:2,
13+
name:'Trubbish',
14+
description:'Wanting more garbage, they follow people who litter. They always belch poison gas.',
15+
votes:2
16+
},{
17+
id:3,
18+
name:'Stunfisk',
19+
description:'Its skin is very hard, so it is unhurt even if stepped on by sumo wrestlers. It smiles when transmitting electricity.',
20+
votes:0
21+
}]
22+
};
2323

2424
expect(spy).to.have.been.called.with(initialState);
2525
});

‎tutorial/03/01.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
constexpect=require('chai').expect;
22

3-
/// load('index.js')
3+
constindex=require('BASE/index.js');
4+
5+
constvoteUp=index.__get__('voteUp');
46

57
describe('01 voteUp Action',()=>{
68

‎tutorial/03/04.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
describe('04 VOTE_UP action type',()=>{
22

3+
constVOTE_UP=index.__get__('VOTE_UP');
4+
35
it('doesn\t exist',()=>{
46
expect(VOTE_UP).to.be.defined;
57
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp