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

Commitf0f557e

Browse files
committed
polish step 7 steps
1 parent090f7b6 commitf0f557e

File tree

9 files changed

+91
-60
lines changed

9 files changed

+91
-60
lines changed

‎coderoad.json

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,11 @@
366366
"07/01"
367367
],
368368
"hints": [
369-
"create\"src/pokemon/index.js\""
369+
"createa file in\"src/pokemon/index.js\""
370370
]
371371
},
372372
{
373-
"description":"take your `VOTE_UP` action type from\"index.js\" and put it in\"src/pokemon/index.js\"",
373+
"description":"copy the `VOTE_UP` action type from\"index.js\" and put it in\"src/pokemon/index.js\". Keep the original version for now, so our app won't break yet.",
374374
"tests": [
375375
"07/02"
376376
],
@@ -379,25 +379,41 @@
379379
]
380380
},
381381
{
382-
"description":"take your `voteUp` action creator from\"src/index.js\" and put it in\"src/pokemon/index.js\". Export it as a [\"named\" export](https://developer.mozilla.org/en/docs/web/javascript/reference/statements/export).",
382+
"description":"also copy the `voteUp` action creator from\"src/index.js\" and put it in\"src/pokemon/index.js\". Export it as a [\"named\" export](https://developer.mozilla.org/en/docs/web/javascript/reference/statements/export).",
383383
"tests": [
384384
"07/03"
385385
],
386386
"hints": [
387387
"move `voteUp` into\"src/pokemon/index.js\"",
388-
"\"src/pokemon/index.js\" should have `const voteUp = id => ({ type: VOTE_UP, payload: { id } });`"
388+
"\"src/pokemon/index.js\" should have `const voteUp = id => ({ type: VOTE_UP, payload: { id } });`",
389+
"make it a named export: `export const voteUp` = ..."
389390
]
390391
},
391392
{
392-
"description":"take your `pokemon` reducer from\"src/index.js\" and put it in\"src/pokemon/index.js\". Export the reducer as a\"default\" export",
393+
"description":"import `voteUp` inside of\"src/index.js\". Also delete the unnecessary\"VOTE_UP\" and 'voteUp' in the same file from before.",
393394
"tests": [
394395
"07/04"
396+
],
397+
"hints": [
398+
"Try this: `import { voteUp } from './pokemon';`"
395399
]
396400
},
397401
{
398-
"description":"in your\"src/index.js\"file, import the action creatorsandreducer in one line of code.",
402+
"description":"take the `defaultPokemon` from\"src/index.js\" andcopy it into\"src/pokemon/index.js\"",
399403
"tests": [
400404
"07/05"
405+
]
406+
},
407+
{
408+
"description":"take your `pokemon` reducer from\"src/index.js\" and put it in\"src/pokemon/index.js\". Export the reducer as a\"default\" export",
409+
"tests": [
410+
"07/06"
411+
]
412+
},
413+
{
414+
"description":"in your\"src/index.js\" file, also import your pokemon reducer. This can be on the same line of code. Delete the unnecessary original\"pokemon\" and\"defaultPokemon\" as well.",
415+
"tests": [
416+
"07/07"
401417
],
402418
"hints": [
403419
"Try this: `import { default as pokemon, voteUp } from './pokemon';`"

‎tutorial/07/01.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
constexpect=require('chai').expect;
2-
const{ resolve}=require('path');
3-
const{ readFileSync}=require('fs');
42

5-
constindexJs=require('BASE/index.js');
6-
constpokemonIndexJs=require('BASE/pokemon/index.js');
3+
constindexJs=require('BASE/src/index.js');
4+
constpokemonIndexJs=require('BASE/src/pokemon/index.js');
75

86
describe('01 "pokemon" folder',()=>{
97

108
it('doesn\'t exist',()=>{
11-
expect(exists('pokemon/index.js')).to.be.true;
9+
expect(exists('src/pokemon/index.js')).to.be.true;
1210
});
1311

1412
});

‎tutorial/07/02.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,4 @@ describe('02 VOTE_UP', () => {
88
expect(VOTE_UP).to.equal('VOTE_UP');
99
});
1010

11-
// index.js - VOTE_UP
12-
constVOTE_UP_in_index=indexJs.__get__('VOTE_UP');
13-
14-
it('should no longer be in the root "index.js" file',()=>{
15-
expect(VOTE_UP_in_index).to.not.be.defined;
16-
});
17-
1811
});

‎tutorial/07/03.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
describe('03 "voteUp"',()=>{
22

3-
it('should be in "pokemon/index.js"',()=>{
3+
it('should be in "src/pokemon/index.js"',()=>{
44
constvoteUp=pokemonIndexJs.__get__('voteUp');
55
expect(voteUp).to.not.be.undefined;
66
expect(typeofvoteUp).to.equal('function');
77
});
88

9-
it('should bea named export',()=>{
10-
constvoteUp=require('BASE/pokemon/index.js').voteUp;
9+
it('should beexported',()=>{
10+
constvoteUp=require('BASE/src/pokemon/index.js').voteUp;
1111
expect(voteUp).to.not.be.undefined;
1212
expect(typeofvoteUp).to.equal('function');
1313
});
1414

15-
it('should no longer be in the root "index.js"',()=>{
16-
constvoteUp=indexJs.__get__('voteUp');
17-
expect(voteUp).not.to.not.be.undefined;
18-
});
19-
2015
});

‎tutorial/07/04.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
1-
describe('04"pokemon" reducer',()=>{
1+
describe('04voteUp',()=>{
22

3-
it('should be in "pokemon/index.js"',()=>{
4-
constpokemon=pokemonIndexJs.__get__('pokemon');
5-
expect(pokemon).to.not.be.undefined;
6-
expect(typeofpokemon).to.equal('function');
7-
expect(pokemon({},{type:'ANY'})).to.deep.equal({});
8-
});
9-
10-
it('should no longer be in the root "index.js"',()=>{
11-
constpokemon=indexJs.__get__('pokemon');
12-
expect(pokemon).to.be.undefined;
13-
});
14-
15-
it('should be a default export',()=>{
16-
constpokemon=require('BASE/pokemon/index.js');
17-
expect(pokemon).to.not.be.undefined;
18-
expect(typeofpokemon).to.equal('function');
19-
expect(pokemon({},{type:'ANY'})).to.deep.equal({});
3+
it('should get imported in "pokemon/index.js"',()=>{
4+
constvoteUp=indexJs.__get__('voteUp');
5+
expect(voteUp).to.not.be.undefined;
6+
expect(typeofvoteUp).to.equal('function');
207
});
218

229
});

‎tutorial/07/05.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
describe('05import',()=>{
1+
describe('05`defaultPokemon`',()=>{
22

3-
it('`voteUp` from "./pokemon" in "index.js"',()=>{
4-
constvoteUp=indexJs.__get__('voteUp');
5-
expect(voteUp).to.not.be.undefined;
6-
expect(typeofvoteUp).to.equal('function');
7-
});
8-
9-
it('`default as pokemon` from "./pokemon" in "index.js"',()=>{
10-
constpokemon=indexJs.__get__('pokemon');
11-
expect(pokemon).to.not.be.undefined;
12-
expect(typeofpokemon).to.equal('function');
3+
it('should be in "src/pokemon/index.js"',()=>{
4+
constdefaultPokemon=pokemonIndexJs.__get__('defaultPokemon');
5+
expect(defaultPokemon).to.not.be.undefined;
6+
expect(defaultPokemon).to.have.length(3);
137
});
148

159
});

‎tutorial/07/06.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
describe('06 "pokemon" reducer',()=>{
2+
3+
it('should be in "pokemon/index.js"',()=>{
4+
constpokemon=pokemonIndexJs.__get__('pokemon');
5+
expect(pokemon).to.not.be.undefined;
6+
expect(typeofpokemon).to.equal('function');
7+
expect(pokemon({},{type:'ANY'})).to.deep.equal({});
8+
});
9+
10+
it('should be a default export',()=>{
11+
constpokemon=require('BASE/src/pokemon/index.js').default;
12+
expect(pokemon).to.not.be.undefined;
13+
expect(typeofpokemon).to.equal('function');
14+
expect(pokemon({},{type:'ANY'})).to.deep.equal({});
15+
});
16+
17+
});

‎tutorial/07/07.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
describe('07 import',()=>{
2+
3+
it('`default as pokemon` from "./pokemon" in "index.js"',()=>{
4+
constpokemon=indexJs.__get__('pokemon');
5+
expect(pokemon).to.not.be.undefined;
6+
expect(typeofpokemon).to.equal('function');
7+
});
8+
9+
});
10+
11+
describe('07 cleanup index.js by deleting',()=>{
12+
13+
it('`VOTE_UP`',()=>{
14+
constVOTE_UP_in_index=indexJs.__get__('VOTE_UP');
15+
expect(VOTE_UP_in_index).to.not.be.defined;
16+
});
17+
18+
it('`defaultPokemon`',()=>{
19+
constdefaultPokemon_in_index=indexJs.__get__('defaultPokemon');
20+
expect(defaultPokemon_in_index).to.not.be.defined;
21+
});
22+
23+
});

‎tutorial/07/index.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,30 @@ Explanation here
55

66
+ create a folder in your base directory called "pokemon" and add a file inside called "index.js"
77
@test('07/01')
8-
@hint('create "src/pokemon/index.js"')
8+
@hint('createa file in"src/pokemon/index.js"')
99

10-
+take your`VOTE_UP` action type from "index.js" and put it in "src/pokemon/index.js"
10+
+copy the`VOTE_UP` action type from "index.js" and put it in "src/pokemon/index.js". Keep the original version for now, so our app won't break yet.
1111
@test('07/02')
1212
@hint('"src/pokemon/index.js" should have`const VOTE_UP = 'VOTE_UP';`')
1313

14-
+take your`voteUp` action creator from "src/index.js" and put it in "src/pokemon/index.js". Export it as a["named" export](https://developer.mozilla.org/en/docs/web/javascript/reference/statements/export).
14+
+also copy the`voteUp` action creator from "src/index.js" and put it in "src/pokemon/index.js". Export it as a["named" export](https://developer.mozilla.org/en/docs/web/javascript/reference/statements/export).
1515
@test('07/03')
1616
@hint('move`voteUp` into "src/pokemon/index.js"')
1717
@hint('"src/pokemon/index.js" should have`const voteUp = id => ({ type: VOTE_UP, payload: { id } });`')
18+
@hint('make it a named export:`export const voteUp` = ...')
1819

19-
+take your`pokemon` reducer from "src/index.js" and put it in "src/pokemon/index.js". Export thereducer as a "default" export
20+
+import`voteUp` inside of "src/index.js". Also delete the unnecessary 'voteUp' in thesame file from before.
2021
@test('07/04')
22+
@hint('Try this:`import { voteUp } from './pokemon';`')
2123

22-
+in your"src/index.js"file, import the action creatorsandreducer in one line of code.
24+
+take the`defaultPokemon` from"src/index.js" andcopy it into "src/pokemon/index.js"
2325
@test('07/05')
26+
27+
+ take your`pokemon` reducer from "src/index.js" and put it in "src/pokemon/index.js". Export the reducer as a "default" export
28+
@test('07/06')
29+
30+
+ in your "src/index.js" file, also import your pokemon reducer. This can be on the same line of code. Delete the unnecessary original "pokemon", "defaultPokemon" and "VOTE_UP" as well.
31+
@test('07/07')
2432
@hint('Try this:`import { default as pokemon, voteUp } from './pokemon';`')
2533

2634
@onPageComplete('Page 7 complete...')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp