@@ -6,6 +6,7 @@ test('uses write mode by default', () => {
66 mode : 'write' ,
77 patterns : [ ] ,
88 parallel : true ,
9+ parallelWorkers : undefined ,
910 help : false ,
1011 } ) ;
1112} ) ;
@@ -20,6 +21,7 @@ test.each([
2021 mode,
2122 patterns : [ ] ,
2223 parallel : true ,
24+ parallelWorkers : undefined ,
2325 help : false ,
2426 } ) ;
2527} ) ;
@@ -29,17 +31,56 @@ test.each(['--no-parallel', '--noParallel'])('disables parallel execution with %
2931 mode : 'write' ,
3032 patterns : [ ] ,
3133 parallel : false ,
34+ parallelWorkers : undefined ,
3235 help : false ,
3336 } ) ;
3437} ) ;
3538
39+ test . each ( [ '--parallel-workers' , '--parallelWorkers' ] ) (
40+ 'configures parallel worker count with %s' ,
41+ ( option ) => {
42+ expect ( parseFmtCLIArgs ( [ option , '3' ] ) ) . toEqual ( {
43+ mode : 'write' ,
44+ patterns : [ ] ,
45+ parallel : true ,
46+ parallelWorkers : 3 ,
47+ help : false ,
48+ } ) ;
49+ } ,
50+ ) ;
51+
52+ test . each ( [ '0' , '-1' , '1.5' , 'invalid' , '9007199254740992' ] ) (
53+ 'rejects invalid parallel worker count %s' ,
54+ ( count ) => {
55+ expect ( ( ) => parseFmtCLIArgs ( [ `--parallel-workers=${ count } ` ] ) ) . toThrow (
56+ 'The --parallel-workers option must be a positive integer.' ,
57+ ) ;
58+ } ,
59+ ) ;
60+
61+ test ( 'rejects using both parallel worker aliases' , ( ) => {
62+ expect ( ( ) => parseFmtCLIArgs ( [ '--parallel-workers' , '2' , '--parallelWorkers' , '3' ] ) ) . toThrow (
63+ 'The --parallel-workers and --parallelWorkers options cannot be used together.' ,
64+ ) ;
65+ } ) ;
66+
67+ test . each ( [
68+ [ '--no-parallel' , '--parallel-workers' ] ,
69+ [ '--noParallel' , '--parallelWorkers' ] ,
70+ ] ) ( 'rejects conflicting parallel options: %s and %s' , ( noParallel , parallelWorkers ) => {
71+ expect ( ( ) => parseFmtCLIArgs ( [ noParallel , parallelWorkers , '2' ] ) ) . toThrow (
72+ 'The --parallel-workers and --no-parallel options cannot be used together.' ,
73+ ) ;
74+ } ) ;
75+
3676test ( 'preserves file paths and globs' , ( ) => {
3777 const patterns = [ 'src/file with spaces.ts' , 'src/**/*.{js,ts}' , '!src/generated/**' ] ;
3878
3979 expect ( parseFmtCLIArgs ( [ patterns [ 0 ] , '--check' , ...patterns . slice ( 1 ) ] ) ) . toEqual ( {
4080 mode : 'check' ,
4181 patterns,
4282 parallel : true ,
83+ parallelWorkers : undefined ,
4384 help : false ,
4485 } ) ;
4586} ) ;
@@ -49,6 +90,7 @@ test('treats arguments after the terminator as paths', () => {
4990 mode : 'check' ,
5091 patterns : [ '--write' , '--help' ] ,
5192 parallel : true ,
93+ parallelWorkers : undefined ,
5294 help : false ,
5395 } ) ;
5496} ) ;
@@ -63,6 +105,7 @@ test('provides command help', () => {
63105 expect ( fmtHelpMessage ) . toContain ( '--check' ) ;
64106 expect ( fmtHelpMessage ) . toContain ( '--list-different' ) ;
65107 expect ( fmtHelpMessage ) . toContain ( '--no-parallel' ) ;
108+ expect ( fmtHelpMessage ) . toContain ( '--parallel-workers <count>' ) ;
66109 expect ( fmtHelpMessage ) . toContain ( '-h, --help' ) ;
67110} ) ;
68111
@@ -78,9 +121,6 @@ test.each([
78121 ) ;
79122} ) ;
80123
81- test . each ( [ '--unknown' , '--no-cache' , '--parallel-workers' ] ) (
82- 'rejects unsupported option %s' ,
83- ( option ) => {
84- expect ( ( ) => parseFmtCLIArgs ( [ option ] ) ) . toThrow ( ) ;
85- } ,
86- ) ;
124+ test . each ( [ '--unknown' , '--no-cache' ] ) ( 'rejects unsupported option %s' , ( option ) => {
125+ expect ( ( ) => parseFmtCLIArgs ( [ option ] ) ) . toThrow ( ) ;
126+ } ) ;
0 commit comments