@@ -9,13 +9,13 @@ describe('makeCmdTasks', () => {
99 } )
1010
1111 it ( 'should return an array' , async ( ) => {
12- const array = await makeCmdTasks ( { commands : 'test' , gitDir, pathsToLint : [ 'test.js' ] } )
12+ const array = await makeCmdTasks ( { commands : 'test' , gitDir, files : [ 'test.js' ] } )
1313 expect ( array ) . toBeInstanceOf ( Array )
1414 } )
1515
1616 it ( 'should work with a single command' , async ( ) => {
1717 expect . assertions ( 4 )
18- const res = await makeCmdTasks ( { commands : 'test' , gitDir, pathsToLint : [ 'test.js' ] } )
18+ const res = await makeCmdTasks ( { commands : 'test' , gitDir, files : [ 'test.js' ] } )
1919 expect ( res . length ) . toBe ( 1 )
2020 const [ linter ] = res
2121 expect ( linter . title ) . toBe ( 'test' )
@@ -30,7 +30,7 @@ describe('makeCmdTasks', () => {
3030 const res = await makeCmdTasks ( {
3131 commands : [ 'test' , 'test2' ] ,
3232 gitDir,
33- pathsToLint : [ 'test.js' ]
33+ files : [ 'test.js' ]
3434 } )
3535 expect ( res . length ) . toBe ( 2 )
3636 const [ linter1 , linter2 ] = res
@@ -58,7 +58,7 @@ describe('makeCmdTasks', () => {
5858 } )
5959
6060 it ( 'should work with function linter returning a string' , async ( ) => {
61- const res = await makeCmdTasks ( { commands : ( ) => 'test' , gitDir, pathsToLint : [ 'test.js' ] } )
61+ const res = await makeCmdTasks ( { commands : ( ) => 'test' , gitDir, files : [ 'test.js' ] } )
6262 expect ( res . length ) . toBe ( 1 )
6363 expect ( res [ 0 ] . title ) . toEqual ( 'test' )
6464 } )
@@ -67,7 +67,7 @@ describe('makeCmdTasks', () => {
6767 const res = await makeCmdTasks ( {
6868 commands : ( ) => [ 'test' , 'test2' ] ,
6969 gitDir,
70- pathsToLint : [ 'test.js' ]
70+ files : [ 'test.js' ]
7171 } )
7272 expect ( res . length ) . toBe ( 2 )
7373 expect ( res [ 0 ] . title ) . toEqual ( 'test' )
@@ -78,24 +78,34 @@ describe('makeCmdTasks', () => {
7878 const res = await makeCmdTasks ( {
7979 commands : filenames => filenames . map ( file => `test ${ file } ` ) ,
8080 gitDir,
81- pathsToLint : [ 'test.js' , 'test2.js' ]
81+ files : [ 'test.js' , 'test2.js' ]
8282 } )
8383 expect ( res . length ) . toBe ( 2 )
84- expect ( res [ 0 ] . title ) . toEqual ( 'test test.js ' )
85- expect ( res [ 1 ] . title ) . toEqual ( 'test test2.js ' )
84+ expect ( res [ 0 ] . title ) . toEqual ( 'test [file] ' )
85+ expect ( res [ 1 ] . title ) . toEqual ( 'test [file] ' )
8686 } )
8787
8888 it ( 'should work with array of mixed string and function linters' , async ( ) => {
8989 const res = await makeCmdTasks ( {
9090 commands : [ ( ) => 'test' , 'test2' , files => files . map ( file => `test ${ file } ` ) ] ,
9191 gitDir,
92- pathsToLint : [ 'test.js' , 'test2.js' , 'test3.js' ]
92+ files : [ 'test.js' , 'test2.js' , 'test3.js' ]
9393 } )
9494 expect ( res . length ) . toBe ( 5 )
9595 expect ( res [ 0 ] . title ) . toEqual ( 'test' )
9696 expect ( res [ 1 ] . title ) . toEqual ( 'test2' )
97- expect ( res [ 2 ] . title ) . toEqual ( 'test test.js' )
98- expect ( res [ 3 ] . title ) . toEqual ( 'test test2.js' )
99- expect ( res [ 4 ] . title ) . toEqual ( 'test test3.js' )
97+ expect ( res [ 2 ] . title ) . toEqual ( 'test [file]' )
98+ expect ( res [ 3 ] . title ) . toEqual ( 'test [file]' )
99+ expect ( res [ 4 ] . title ) . toEqual ( 'test [file]' )
100+ } )
101+
102+ it ( 'should generate short names for function tasks with long file list' , async ( ) => {
103+ const res = await makeCmdTasks ( {
104+ commands : filenames => `test ${ filenames . map ( file => `--file ${ file } ` ) . join ( ' ' ) } ` ,
105+ gitDir,
106+ files : Array ( 100 ) . fill ( 'file.js' ) // 100 times `file.js`
107+ } )
108+ expect ( res . length ) . toBe ( 1 )
109+ expect ( res [ 0 ] . title ) . toEqual ( 'test --file [file]' )
100110 } )
101111} )
0 commit comments