11import test from 'ava'
2+ import { each } from 'test-each'
23
34// eslint-disable-next-line no-restricted-imports
4- import { DEFAULT_EXIT_CODE } from './exit.js'
5+ import {
6+ DEFAULT_EXIT_CODE ,
7+ INVALID_OPTS_EXIT_CODE ,
8+ MAX_EXIT_CODE ,
9+ } from './exit.js'
510import { handleError } from './helpers/main.test.js'
611
712test . serial ( 'Default exit code' , ( t ) => {
@@ -10,11 +15,15 @@ test.serial('Default exit code', (t) => {
1015 t . is ( exitCodeAfter , DEFAULT_EXIT_CODE )
1116} )
1217
13- test . serial ( 'Custom exit code' , ( t ) => {
14- const customExitCode = 2
15- const { exitCode, exitCodeAfter } = handleError ( '' , {
16- exitCode : customExitCode ,
17- } )
18- t . is ( exitCode , customExitCode )
19- t . is ( exitCodeAfter , customExitCode )
20- } )
18+ each (
19+ [ 0 , 2 , INVALID_OPTS_EXIT_CODE , MAX_EXIT_CODE ] ,
20+ ( { title } , customExitCode ) => {
21+ test . serial ( `Custom exit code | ${ title } ` , ( t ) => {
22+ const { exitCode, exitCodeAfter } = handleError ( '' , {
23+ exitCode : customExitCode ,
24+ } )
25+ t . is ( exitCode , customExitCode )
26+ t . is ( exitCodeAfter , customExitCode )
27+ } )
28+ } ,
29+ )
0 commit comments