File tree Expand file tree Collapse file tree 8 files changed +64
-22
lines changed Expand file tree Collapse file tree 8 files changed +64
-22
lines changed Original file line number Diff line number Diff line change 427
427
"description" : " The power of middleware with \" redux-logger\" .\n\n Explanation here." ,
428
428
"tasks" : [
429
429
{
430
- "description" : " import `applyMiddleware` in \" index.js\" " ,
430
+ "description" : " import `applyMiddleware` in \" index.js\" from the \" redux \" package. It is a named import. " ,
431
431
"tests" : [
432
432
" 08/01"
433
433
],
439
439
"description" : " set the second param in createStore to `applyMiddleware()`" ,
440
440
"tests" : [
441
441
" 08/02"
442
+ ],
443
+ "hints" : [
444
+ " Try this: `createStore(reducers, applyMiddleware());`"
442
445
]
443
446
},
444
447
{
445
448
"description" : " install \" redux-logger\" using npm" ,
446
449
"tests" : [
447
450
" 08/03"
451
+ ],
452
+ "hints" : [
453
+ " Try this: `npm install --save-dev redux-logger`"
448
454
]
449
455
},
450
456
{
451
- "description" : " create a \" logger\" as the result of `createLogger()` " ,
457
+ "description" : " import `createLogger` from the \" redux- logger\" package. It is a default import. " ,
452
458
"tests" : [
453
459
" 08/04"
460
+ ],
461
+ "hints" : [
462
+ " Try this: `import createLogger from 'redux-logger';`"
454
463
]
455
464
},
456
465
{
457
- "description" : " pass \" logger\" into `applyMiddleware ()`" ,
466
+ "description" : " create a \" logger\" as the result of `createLogger ()`" ,
458
467
"tests" : [
459
468
" 08/05"
469
+ ],
470
+ "hints" : [
471
+ " Note that `logger` should be above `store`." ,
472
+ " Try this: `const logger = createLogger()`"
473
+ ]
474
+ },
475
+ {
476
+ "description" : " pass \" logger\" into `applyMiddleware()`" ,
477
+ "tests" : [
478
+ " 08/06"
479
+ ],
480
+ "hints" : [
481
+ " Try this: `applyMiddleware(logger)`"
460
482
]
461
483
}
462
484
],
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ chai.use(spies);
5
5
6
6
let spy = chai . spy . on ( console , 'log' ) ;
7
7
8
- const indexJs = require ( 'BASE/index.js' ) ;
8
+ const indexJs = require ( 'BASE/src/ index.js' ) ;
9
9
10
10
describe ( '01 applyMiddleware' , ( ) => {
11
11
Original file line number Diff line number Diff line change 1
1
describe ( '02 createStore' , ( ) => {
2
2
3
- // it('should call applyMiddleware', () => {
4
- // console.log("createStore", createStore);
5
- // });
3
+ it ( 'should call applyMiddleware' , ( ) => {
4
+ const regex = / ^ [ a - z ] + \s s t o r e \s ? = .* a p p l y M i d d l e w a r e \( .+ \) / m;
5
+ expect ( indexJs . __text__ . to . match ( regex ) ;
6
+ } ) ;
6
7
7
8
} ) ;
Original file line number Diff line number Diff line change 1
- describe ( '03 redux-logger' )
1
+ describe ( '03 redux-logger' , ( ) => {
2
2
3
3
it ( 'should be installed. `npm i -D redux-logger`' , ( ) => {
4
4
expect ( exists ( 'node_modules/redux-logger' ) ) . to . be . true ;
Original file line number Diff line number Diff line change 1
- describe ( '04 logger' , ( ) => {
2
-
3
- const logger = indexJs . __get__ ( 'logger' ) ;
4
-
5
- it ( 'doesn\'t exist' , ( ) => {
6
- expect ( logger ) . to . not . be . undefined ;
7
- } ) ;
8
-
9
- it ( 'should be set to `createLogger()`' , ( ) => {
1
+ describe ( '04 import' , ( ) => {
10
2
3
+ it ( 'createLogger' , ( ) => {
4
+ const createLogger = indexJs . __get__ ( 'createLogger' ) ;
5
+ expect ( createLogger ) . to . not . be . undefined ;
6
+ expect ( typeof createLogger ) . to . equal ( 'function' ) ;
11
7
} ) ;
12
8
13
9
} ) ;
Original file line number Diff line number Diff line change 1
- describe ( '05 applyMiddleware logger' , ( ) => {
1
+ describe ( '05 logger' , ( ) => {
2
2
3
- it ( '' , ( ) => {
3
+ const logger = indexJs . __get__ ( 'logger' ) ;
4
+
5
+ it ( 'doesn\'t exist' , ( ) => {
6
+ expect ( logger ) . to . not . be . undefined ;
7
+ } ) ;
8
+
9
+ it ( 'should be set to `createLogger()`' , ( ) => {
4
10
5
11
} ) ;
6
12
Original file line number Diff line number Diff line change
1
+ describe ( '06 logger' , ( ) => {
2
+
3
+ it ( 'should be called by applyMiddleware' , ( ) => {
4
+ const regex = / ^ [ a - z ] + \s s t o r e \s ? = .+ a p p l y M i d d l e w a r e \( .* l o g g e r .* \) / m;
5
+ expect ( indexJs . __text__ ) . to . match ( regex ) ;
6
+ } ) ;
7
+
8
+ } ) ;
Original file line number Diff line number Diff line change @@ -3,20 +3,29 @@ The power of middleware with "redux-logger".
3
3
4
4
Explanation here.
5
5
6
- + import ` applyMiddleware ` in "index.js"
6
+ + import ` applyMiddleware ` in "index.js" from the "redux" package. It is a named import.
7
7
@test ('08/01')
8
8
@action (open('src/index.js'))
9
9
10
10
+ set the second param in createStore to ` applyMiddleware() `
11
11
@test ('08/02')
12
+ @hint ('Try this: ` createStore(reducers, applyMiddleware()); ` ')
12
13
13
14
+ install "redux-logger" using npm
14
15
@test ('08/03')
16
+ @hint ('Try this: ` npm install --save-dev redux-logger ` ')
15
17
16
- + create a " logger" as the result of ` createLogger() `
18
+ + import ` createLogger ` from the "redux- logger" package. It is a default import.
17
19
@test ('08/04')
20
+ @hint ('Try this: ` import createLogger from 'redux-logger'; ` ')
18
21
19
- + pass "logger" into ` applyMiddleware ()`
22
+ + create a "logger" as the result of ` createLogger ()`
20
23
@test ('08/05')
24
+ @hint ('Note that ` logger ` should be above ` store ` .')
25
+ @hint ('Try this: ` const logger = createLogger() ` ')
26
+
27
+ + pass "logger" into ` applyMiddleware() `
28
+ @test ('08/06')
29
+ @hint ('Try this: ` applyMiddleware(logger) ` ')
21
30
22
31
@onPageComplete ('Look in the console')
You can’t perform that action at this time.
0 commit comments