@@ -52,4 +52,34 @@ describe('makeCmdTasks', () => {
52
52
shell : false
53
53
} )
54
54
} )
55
+
56
+ it ( 'should work with function linter returning a string' , async ( ) => {
57
+ const res = await makeCmdTasks ( ( ) => 'test' , false , gitDir , [ 'test.js' ] )
58
+ expect ( res . length ) . toBe ( 1 )
59
+ expect ( res [ 0 ] . title ) . toEqual ( 'test' )
60
+ } )
61
+
62
+ it ( 'should work with function linter returning array of string' , async ( ) => {
63
+ const res = await makeCmdTasks ( ( ) => [ 'test' , 'test2' ] , false , gitDir , [ 'test.js' ] )
64
+ expect ( res . length ) . toBe ( 1 )
65
+ expect ( res [ 0 ] . title ) . toEqual ( 'test' )
66
+ } )
67
+
68
+ it ( 'should work with function linter accepting arguments' , async ( ) => {
69
+ const res = await makeCmdTasks (
70
+ filenames => filenames . map ( file => `test ${ file } ` ) ,
71
+ false ,
72
+ gitDir ,
73
+ [ 'test.js' ]
74
+ )
75
+ expect ( res . length ) . toBe ( 1 )
76
+ expect ( res [ 0 ] . title ) . toEqual ( 'test [file]' )
77
+ } )
78
+
79
+ it ( 'should work with array of mixed string and function linters' , async ( ) => {
80
+ const res = await makeCmdTasks ( [ ( ) => 'test' , 'test2' ] , false , gitDir , [ 'test.js' ] )
81
+ expect ( res . length ) . toBe ( 2 )
82
+ expect ( res [ 0 ] . title ) . toEqual ( 'test' )
83
+ expect ( res [ 1 ] . title ) . toEqual ( 'test2' )
84
+ } )
55
85
} )
0 commit comments