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

Commitc5a1e23

Browse files
committed
complete step 10 tasks and tests
1 parent6ba1597 commitc5a1e23

File tree

8 files changed

+68
-22
lines changed

8 files changed

+68
-22
lines changed

‎coderoad.json

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -584,36 +584,56 @@
584584
],
585585
"actions": [
586586
"open('src/index.js')"
587+
],
588+
"hints": [
589+
"Try this: `npm install --save redux-thunk`"
587590
]
588591
},
589592
{
590-
"description":"importthunk from\"redux-thunk\"",
593+
"description":"import`reduxThunk` from\"redux-thunk\"",
591594
"tests": [
592595
"10/02"
596+
],
597+
"hints": [
598+
"Try this: `import reduxThunk from 'redux-thunk';`"
593599
]
594600
},
595601
{
596-
"description":"addthunk to applyMiddleware. The logger should always go last",
602+
"description":"add`reduxThunk` to applyMiddleware. The logger should always go last",
597603
"tests": [
598604
"10/03"
605+
],
606+
"hints": [
607+
"Try this: `applyMiddleware(reduxThunk, logger)`"
599608
]
600609
},
601610
{
602-
"description":"change the voteUp action creator to return a thunk with the param of\"dispatch\"",
611+
"description":"change the`voteUp` action creator in\"src/pokemon/index.js\" to return a thunk with the param of\"dispatch\"",
603612
"tests": [
604613
"10/04"
614+
],
615+
"hints": [
616+
"`Try this: `const voteUp => (id) => (dispatch) => {}`'"
605617
]
606618
},
607619
{
608-
"description":"voteUp should dispatch VOTE_UP",
620+
"description":"voteUp` should dispatch`VOTE_UP",
609621
"tests": [
610622
"10/05"
623+
],
624+
"hints": [
625+
"Try this: `const voteUp => (id) => (dispatch) => dispatch(voteUp(id))`"
611626
]
612627
},
613628
{
614-
"description":"voteUp should dispatch sortByPopularity after each vote",
629+
"description":"`voteUp` shouldalsodispatch`sortByPopularity after each vote",
615630
"tests": [
616631
"10/06"
632+
],
633+
"hints": [
634+
"Try this: `const voteUp => (id) => (dispatch) => { ... dispatches ... }`",
635+
"Add: `dispatch(sortByPopularity());`",
636+
"Try this: `const voteUp => (id) => (dispatch) => { dispatch(voteUp(id); dispatch(sortByPopularity()))}`"
617637
]
618638
}
619639
],

‎tutorial/10/01.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ chai.use(spies);
55

66
letspy=chai.spy.on(console,'log');
77

8-
constindexJs=require('BASE/index.js');
8+
constindexJs=require('BASE/src/index.js');
9+
constpokemonIndexJs=require('BASE/src/pokemon/index.js');
10+
11+
constvoteUp=pokemonIndexJs.__get__('voteUp');
912

1013
describe('01 redux thunk',()=>{
1114

1215
it('should be installed',()=>{
13-
expect(exist('node_modules/redux-thunk').to.be.true;
16+
expect(exists('node_modules/redux-thunk')).to.be.true;
1417
});
1518

1619
});

‎tutorial/10/02.js

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

3-
constthunk=indexJs.__get__('thunk');
3+
constreduxThunk=indexJs.__get__('reduxThunk');
44

55
it('should be imported',()=>{
6-
expect(thunk).to.not.be.undefined;
6+
expect(reduxThunk).to.not.be.undefined;
7+
constregex=/f/;
8+
expect(reduxThunk.toString()).to.match(regex);
79
});
810

9-
// more specific check
10-
1111
});

‎tutorial/10/03.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
describe('03 applyMiddleware thunk',()=>{
2-
1+
describe('03 thunk',()=>{
32

3+
it('should be loaded with `applyMiddleware`',()=>{
4+
constregex=/^[a-z]+\sstore\s?=.+applyMiddleware\(.*reduxThunk.*\)/m;
5+
expect(indexJs.__text__).to.match(regex);
6+
});
47

58
});

‎tutorial/10/04.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
describe('04 voteUp',()=>{
22

3+
constvoteUp=pokemonIndexJs.__get__('voteUp');
4+
5+
it('should return a thunk',()=>{
6+
expect(typeofvoteUp(1)).to.equal('function');
7+
});
8+
39
it('should return a thunk with a "dispatch" param',()=>{
4-
10+
constregex=/dispatch/;
11+
expect(voteUp(1)).to.have.length.at.least(1);
12+
expect(voteUp(1).toString()).to.match(regex);
513
});
614

15+
16+
717
});

‎tutorial/10/05.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
describe('05 voteUp',()=>{
22

33
it('should dispatch a VOTE_UP action',()=>{
4-
4+
constregex=/dispatch\(\s?\{\s?type\s?:\s?VOTE_UP.*\}\s?\)/;
5+
expect(voteUp(1).toString()).to.match(regex);
56
});
67

78
});

‎tutorial/10/06.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
describe('06 voteUp',()=>{
22

33
it('should dispatch a SORT_BY_POPULARITY action',()=>{
4-
4+
constregex=/dispatch\s?\(\s?sortByPopularity\s?\(.*\)\s?\)/m;
5+
expect(voteUp(1).toString()).to.match(regex);
56
});
67

78
});

‎tutorial/10/index.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,28 @@ Using thunks for async actions.
44
+ install "redux-thunk" as a dependency
55
@test('10/01')
66
@action(open('src/index.js'))
7+
@hint('Try this:`npm install --save redux-thunk`')
78

8-
+ importthunk from "redux-thunk"
9+
+ import`reduxThunk` from "redux-thunk"
910
@test('10/02')
11+
@hint('Try this:`import reduxThunk from 'redux-thunk';`')
1012

11-
+ addthunk to applyMiddleware. The logger should always go last
13+
+ add`reduxThunk` to applyMiddleware. The logger should always go last
1214
@test('10/03')
15+
@hint('Try this:`applyMiddleware(reduxThunk, logger)`')
1316

14-
+ change the voteUp action creator to return a thunk with the param of "dispatch"
17+
+ change the`voteUp` action creator in "src/pokemon/index.js" to return a thunk with the param of "dispatch"
1518
@test('10/04')
19+
@hint(`Try this:`const voteUp => (id) => (dispatch) => {}`')
1620

17-
+ voteUp should dispatch VOTE_UP
21+
+`voteUp` should dispatch`VOTE_UP`
1822
@test('10/05')
23+
@hint('Try this:`const voteUp => (id) => (dispatch) => dispatch(voteUp(id))`')
1924

20-
+ voteUp should dispatch sortByPopularity after each vote
25+
+`voteUp` shouldalsodispatch`sortByPopularity after each vote
2126
@test('10/06')
27+
@hint('Try this:`const voteUp => (id) => (dispatch) => { ... dispatches ... }`')
28+
@hint('Add:`dispatch(sortByPopularity());`')
29+
@hint('Try this:`const voteUp => (id) => (dispatch) => { dispatch(voteUp(id); dispatch(sortByPopularity()))}`')
2230

2331
@onPageComplete('')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp