File tree 2 files changed +27
-1
lines changed
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ module.exports = heal;
154
154
function matchRecipes ( recipes , contextName ) {
155
155
return Object . entries ( recipes )
156
156
. 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 )
158
158
. map ( ( [ name , recipe ] ) => {
159
159
recipe . name = name ;
160
160
return recipe ;
Original file line number Diff line number Diff line change @@ -26,6 +26,32 @@ describe('heal', () => {
26
26
expect ( heal . hasCorrespondingRecipes ( { name : 'click' } ) ) . to . be . true ;
27
27
} ) ;
28
28
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
+
29
55
it ( 'should have corresponding recipes' , ( ) => {
30
56
heal . recipes = { test : { steps : [ 'step1' , 'step2' ] , fn : ( ) => { } } } ;
31
57
heal . contextName = 'TestSuite' ;
You can’t perform that action at this time.
0 commit comments