File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ module.exports = heal;
154154function  matchRecipes ( recipes ,  contextName )  { 
155155  return  Object . entries ( recipes ) 
156156    . filter ( ( [ ,  recipe ] )  =>  ! contextName  ||  ! recipe . grep  ||  new  RegExp ( recipe . grep ) . test ( contextName ) ) 
157-     . sort ( ( [ ,  a ] ,  [ ,  b ] )  =>  b . priority  -  a . priority ) 
157+     . sort ( ( [ ,  a ] ,  [ ,  b ] )  =>  a . priority  -  b . priority ) 
158158    . map ( ( [ name ,  recipe ] )  =>  { 
159159      recipe . name  =  name ; 
160160      return  recipe ; 
Original file line number Diff line number Diff line change @@ -26,6 +26,32 @@ describe('heal', () => {
2626    expect ( heal . hasCorrespondingRecipes ( {  name : 'click'  } ) ) . to . be . true ; 
2727  } ) ; 
2828
29+   it ( 'should respect the priority of recipes' ,  async  ( )  =>  { 
30+     heal . addRecipe ( 'secondPrior' ,  { 
31+       priority : 2 , 
32+       steps : [ 'click' ] , 
33+       fn : async  ( )  =>  { 
34+         return  ( {  I } )  =>  { 
35+           I . refreshPage ( ) ; 
36+         } ; 
37+       } , 
38+     } ) ; 
39+ 
40+     heal . addRecipe ( 'firstPrior' ,  { 
41+       priority : 1 , 
42+       steps : [ 'refresh' ] , 
43+       fn : async  ( )  =>  { 
44+         return  ( {  I } )  =>  { 
45+           I . refreshPage ( ) ; 
46+           I . refreshPage ( ) ; 
47+         } ; 
48+       } , 
49+     } ) ; 
50+ 
51+     expect ( ( await  heal . getCodeSuggestions ( { } ) ) [ 0 ] . name ) . to . equal ( 'firstPrior' ) ; 
52+     expect ( ( await  heal . getCodeSuggestions ( { } ) ) [ 1 ] . name ) . to . equal ( 'secondPrior' ) ; 
53+   } ) ; 
54+ 
2955  it ( 'should have corresponding recipes' ,  ( )  =>  { 
3056    heal . recipes  =  {  test : {  steps : [ 'step1' ,  'step2' ] ,  fn : ( )  =>  { }  }  } ; 
3157    heal . contextName  =  'TestSuite' ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments