File tree 6 files changed +10
-23
lines changed
6 files changed +10
-23
lines changed Original file line number Diff line number Diff line change 531
531
]
532
532
},
533
533
{
534
- "description" : " add a `SORT_BY_POPULARITY` case that returns `pokemon.sort();`" ,
534
+ "description" : " back in \" src/pokemon/index.js \" , add a `SORT_BY_POPULARITY` case that returns `pokemon.sort();`" ,
535
535
"tests" : [
536
536
" 09/05"
537
537
],
548
548
" Try this: `case SORT_BY_POPULARITY: return pokemon.sort(sortByVotes)`"
549
549
],
550
550
"actions" : [
551
- " insert('\n function sortByVotes(a, b) {\n switch(true) {\n case a.votes > b.votes:\n return 1;\n case a.votes < b.votes:\n return -1;\n default: return 0;\n }\n }\n\n ')"
551
+ " insert('\n function sortByVotes(a, b) {\n switch(true) {\n case a.votes < b.votes:\n return 1;\n case a.votes > b.votes:\n return -1;\n default: return 0;\n }\n }\n\n ')"
552
552
]
553
553
},
554
554
{
Original file line number Diff line number Diff line change 1
1
describe ( '04 sortByPopularity action' , ( ) => {
2
2
3
3
it ( 'should be dispatched' , ( ) => {
4
- const regex = / s t o r e .d i s p a t c h \s ? \( \s ? s o r t B y P o p u l a r i t y \( \s ? \) \s ? ) / ;
4
+ const regex = / s t o r e .d i s p a t c h \s ? \( \s ? s o r t B y P o p u l a r i t y \( \s ? \) \s ? \) / m ;
5
5
expect ( indexJs . __text__ ) . to . match ( regex ) ;
6
6
} ) ;
7
7
Original file line number Diff line number Diff line change @@ -3,12 +3,12 @@ describe('05 pokemon reducer', () => {
3
3
const pokemon = pokemonIndexJs . __get__ ( 'pokemon' ) ;
4
4
5
5
it ( 'has a SORT_BY_POPULARITY case' , ( ) => {
6
- const regex = / c a s e \s ? + S O R T _ B Y _ P O P U L A R I T Y / ;
6
+ const regex = / c a s e \s + ? S O R T _ B Y _ P O P U L A R I T Y \s ? : / ;
7
7
expect ( pokemon . toString ( ) ) . to . match ( regex ) ;
8
8
} ) ;
9
9
10
10
it ( 'case SORT_BY_POPULARITY should sort pokemon' , ( ) => {
11
- const regex = / p o k e m o n .s o r t ( . * ) / ;
11
+ const regex = / c a s e \s + ? S O R T _ B Y _ P O P U L A R I T Y \s ? : \n ? \s + ? r e t u r n \s + ? p o k e m o n .s o r t \( / ;
12
12
expect ( pokemon . toString ( ) ) . to . match ( regex ) ;
13
13
} ) ;
14
14
Original file line number Diff line number Diff line change 1
1
describe ( '06 sortByVotes function' , ( ) => {
2
2
3
- if ( Number ( process . env . TASK_POSITION ) <= 5 ) {
3
+ // if (Number(process.env.TASK_POSITION) <= 5) {
4
4
5
5
const sortByVotes = pokemonIndexJs . __get__ ( 'sortByVotes' ) ;
6
6
@@ -18,19 +18,11 @@ describe('06 sortByVotes function', () => {
18
18
expect ( pokemon . toString ( ) ) . to . match ( regex ) ;
19
19
} ) ;
20
20
21
- it ( 'should sort a list of objects with vote' , ( ) => {
22
- const list = [ { votes : 3 } , { votes : 1 } , { votes : 2 } ] ;
23
- expect ( list . sort ( sortByVotes ) ) . to . not . deep . equal ( list ) ;
24
- } ) ;
25
-
26
21
it ( 'should sort a list in descending order' , ( ) => {
27
22
const list = [ { votes : 3 } , { votes : 1 } , { votes : 2 } ] ;
28
23
const expected = [ { votes : 3 } , { votes : 2 } , { votes : 1 } ] ;
29
24
expect ( list . sort ( sortByVotes ) ) . to . deep . equal ( expected ) ;
30
25
} ) ;
31
26
32
- } else {
33
- it ( 'passes' , ( ) => expect ( true ) . to . be ( true ) ) ;
34
- }
35
-
27
+ // }
36
28
} ) ;
Original file line number Diff line number Diff line change @@ -14,11 +14,6 @@ describe('07 sortByKey function', () => {
14
14
expect ( sortByKey ) . to . have . length ( 1 ) ;
15
15
} ) ;
16
16
17
- it ( 'should sort a list of objects by a key' , ( ) => {
18
- const list = [ { a : 3 } , { a : 1 } , { a : 2 } ] ;
19
- expect ( list . sort ( sortByKey ( 'a' ) ) ) . to . not . deep . equal ( list ) ;
20
- } ) ;
21
-
22
17
it ( 'should sort a list in descending order' , ( ) => {
23
18
const list = [ { a : 3 } , { a : 1 } , { a : 2 } ] ;
24
19
const expected = [ { a : 3 } , { a : 2 } , { a : 1 } ] ;
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ Sort pokemon by votes
33
33
@hint ('use ` store.dispatch(actionCreator) ` ')
34
34
@hint ('Try this: ` store.dispatch(sortByPopularity()) ` ')
35
35
36
- + add a ` SORT_BY_POPULARITY ` case that returns ` pokemon.sort(); `
36
+ + back in "src/pokemon/index.js", add a ` SORT_BY_POPULARITY ` case that returns ` pokemon.sort(); `
37
37
@test ('09/05')
38
38
@hint ('Try this: ` case SORT_BY_POPULARITY: return pokemon.sort() ` ')
39
39
@@ -45,9 +45,9 @@ Sort pokemon by votes
45
45
46
46
function sortByVotes(a, b) {
47
47
switch(true) {
48
- case a.votes > b.votes:
49
- return 1;
50
48
case a.votes < b.votes:
49
+ return 1;
50
+ case a.votes > b.votes:
51
51
return -1;
52
52
default: return 0;
53
53
}
You can’t perform that action at this time.
0 commit comments