File tree Expand file tree Collapse file tree 6 files changed +10
-23
lines changed Expand file tree Collapse file tree 6 files changed +10
-23
lines changed Original file line number Diff line number Diff line change 531531 ]
532532 },
533533 {
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();`" ,
535535 "tests" : [
536536 " 09/05"
537537 ],
548548 " Try this: `case SORT_BY_POPULARITY: return pokemon.sort(sortByVotes)`"
549549 ],
550550 "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 ')"
552552 ]
553553 },
554554 {
Original file line number Diff line number Diff line change 11describe ( '04 sortByPopularity action' , ( ) => {
22
33 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 ;
55 expect ( indexJs . __text__ ) . to . match ( regex ) ;
66 } ) ;
77
Original file line number Diff line number Diff line change @@ -3,12 +3,12 @@ describe('05 pokemon reducer', () => {
33 const pokemon = pokemonIndexJs . __get__ ( 'pokemon' ) ;
44
55 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 ? : / ;
77 expect ( pokemon . toString ( ) ) . to . match ( regex ) ;
88 } ) ;
99
1010 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 \( / ;
1212 expect ( pokemon . toString ( ) ) . to . match ( regex ) ;
1313 } ) ;
1414
Original file line number Diff line number Diff line change 11describe ( '06 sortByVotes function' , ( ) => {
22
3- if ( Number ( process . env . TASK_POSITION ) <= 5 ) {
3+ // if (Number(process.env.TASK_POSITION) <= 5) {
44
55 const sortByVotes = pokemonIndexJs . __get__ ( 'sortByVotes' ) ;
66
@@ -18,19 +18,11 @@ describe('06 sortByVotes function', () => {
1818 expect ( pokemon . toString ( ) ) . to . match ( regex ) ;
1919 } ) ;
2020
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-
2621 it ( 'should sort a list in descending order' , ( ) => {
2722 const list = [ { votes : 3 } , { votes : 1 } , { votes : 2 } ] ;
2823 const expected = [ { votes : 3 } , { votes : 2 } , { votes : 1 } ] ;
2924 expect ( list . sort ( sortByVotes ) ) . to . deep . equal ( expected ) ;
3025 } ) ;
3126
32- } else {
33- it ( 'passes' , ( ) => expect ( true ) . to . be ( true ) ) ;
34- }
35-
27+ // }
3628} ) ;
Original file line number Diff line number Diff line change @@ -14,11 +14,6 @@ describe('07 sortByKey function', () => {
1414 expect ( sortByKey ) . to . have . length ( 1 ) ;
1515 } ) ;
1616
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-
2217 it ( 'should sort a list in descending order' , ( ) => {
2318 const list = [ { a : 3 } , { a : 1 } , { a : 2 } ] ;
2419 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
3333@hint ('use ` store.dispatch(actionCreator) ` ')
3434@hint ('Try this: ` store.dispatch(sortByPopularity()) ` ')
3535
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(); `
3737@test ('09/05')
3838@hint ('Try this: ` case SORT_BY_POPULARITY: return pokemon.sort() ` ')
3939
@@ -45,9 +45,9 @@ Sort pokemon by votes
4545
4646function sortByVotes(a, b) {
4747 switch(true) {
48- case a.votes > b.votes:
49- return 1;
5048 case a.votes < b.votes:
49+ return 1;
50+ case a.votes > b.votes:
5151 return -1;
5252 default: return 0;
5353 }
You can’t perform that action at this time.
0 commit comments