@@ -115,3 +115,38 @@ test('cli option takes precedence over config', async t => {
115115 // i.e make sure absent cli flags are not parsed as `false`
116116 await t . throws ( main ( [ '--stdin' ] , { input} ) ) ;
117117} ) ;
118+
119+ test ( 'space option with number value' , async t => {
120+ const cwd = path . join ( __dirname , 'fixtures/space' ) ;
121+ const { stdout} = await t . throws ( main ( [ '--space=4' , 'one-space.js' ] , { cwd} ) ) ;
122+ t . true ( stdout . includes ( 'Expected indentation of 4 spaces' ) ) ;
123+ } ) ;
124+
125+ test ( 'space option as boolean' , async t => {
126+ const cwd = path . join ( __dirname , 'fixtures/space' ) ;
127+ const { stdout} = await t . throws ( main ( [ '--space' ] , { cwd} ) ) ;
128+ t . true ( stdout . includes ( 'Expected indentation of 2 spaces' ) ) ;
129+ } ) ;
130+
131+ test ( 'space option as boolean with filename' , async t => {
132+ const cwd = path . join ( __dirname , 'fixtures/space' ) ;
133+ const { stdout} = await main ( [ '--reporter=json' , '--space' , 'two-spaces.js' ] , {
134+ cwd,
135+ reject : false
136+ } ) ;
137+ const reports = JSON . parse ( stdout ) ;
138+
139+ // Only the specified file was checked (filename was not the value of `space`)
140+ t . is ( reports . length , 1 ) ;
141+
142+ // The default space value of 2 was expected
143+ t . is ( reports [ 0 ] . errorCount , 0 ) ;
144+ } ) ;
145+
146+ test ( 'space option with boolean strings' , async t => {
147+ const cwd = path . join ( __dirname , 'fixtures/space' ) ;
148+ const trueResult = await t . throws ( main ( [ '--space=true' ] , { cwd} ) ) ;
149+ const falseResult = await t . throws ( main ( [ '--space=false' ] , { cwd} ) ) ;
150+ t . true ( trueResult . stdout . includes ( 'Expected indentation of 2 spaces' ) ) ;
151+ t . true ( falseResult . stdout . includes ( 'Expected indentation of 1 tab' ) ) ;
152+ } ) ;
0 commit comments