@@ -606,20 +606,62 @@ describe('namespace-scoped options', () => {
606606 } ) ;
607607} ) ;
608608
609- test ( 'should reject config with schema validation errors' , async ( ) => {
610- const result = await spawnPromisified ( process . execPath , [
611- '--experimental-config-file' ,
612- fixtures . path ( 'rc/invalid-schema-type.json' ) ,
613- '-p' , '"Hello"' ,
614- ] ) ;
615- assert . match ( result . stderr , / I n v a l i d c o n f i g u r a t i o n / ) ;
616- assert . strictEqual ( result . code , 9 ) ;
617- } ) ;
609+ describe ( 'JSON Schema validation' , ( ) => {
610+ test ( 'rejects boolean option with string value' , async ( ) => {
611+ const result = await spawnPromisified ( process . execPath , [
612+ '--experimental-config-file' ,
613+ fixtures . path ( 'rc/invalid-schema-type.json' ) ,
614+ '-p' , '"Hello"' ,
615+ ] ) ;
616+ assert . match ( result . stderr , / I n v a l i d c o n f i g u r a t i o n / ) ;
617+ assert . strictEqual ( result . code , 9 ) ;
618+ } ) ;
618619
619- test ( 'process.versions.ata should be defined' , async ( ) => {
620- const result = await spawnPromisified ( process . execPath , [
621- '-p' , 'process.versions.ata' ,
622- ] ) ;
623- assert . match ( result . stdout , / \d + \. \d + \. \d + / ) ;
624- assert . strictEqual ( result . code , 0 ) ;
620+ test ( 'rejects number option with string value' , async ( ) => {
621+ const result = await spawnPromisified ( process . execPath , [
622+ '--experimental-config-file' ,
623+ fixtures . path ( 'rc/invalid-schema-number-as-string.json' ) ,
624+ '-p' , '"Hello"' ,
625+ ] ) ;
626+ assert . match ( result . stderr , / I n v a l i d c o n f i g u r a t i o n / ) ;
627+ assert . strictEqual ( result . code , 9 ) ;
628+ } ) ;
629+
630+ test ( 'rejects array option with boolean value' , async ( ) => {
631+ const result = await spawnPromisified ( process . execPath , [
632+ '--experimental-config-file' ,
633+ fixtures . path ( 'rc/invalid-schema-array-as-bool.json' ) ,
634+ '-p' , '"Hello"' ,
635+ ] ) ;
636+ assert . match ( result . stderr , / I n v a l i d c o n f i g u r a t i o n / ) ;
637+ assert . strictEqual ( result . code , 9 ) ;
638+ } ) ;
639+
640+ test ( 'rejects array with wrong item type' , async ( ) => {
641+ const result = await spawnPromisified ( process . execPath , [
642+ '--experimental-config-file' ,
643+ fixtures . path ( 'rc/invalid-schema-nested-type.json' ) ,
644+ '-p' , '"Hello"' ,
645+ ] ) ;
646+ assert . match ( result . stderr , / I n v a l i d c o n f i g u r a t i o n / ) ;
647+ assert . strictEqual ( result . code , 9 ) ;
648+ } ) ;
649+
650+ test ( 'accepts valid config with mixed types' , async ( ) => {
651+ const result = await spawnPromisified ( process . execPath , [
652+ '--experimental-config-file' ,
653+ fixtures . path ( 'rc/valid-schema-all-types.json' ) ,
654+ '-e' , 'process.exit(0)' ,
655+ ] ) ;
656+ assert . strictEqual ( result . code , 0 ) ;
657+ } ) ;
658+
659+ test ( 'accepts empty object config' , async ( ) => {
660+ const result = await spawnPromisified ( process . execPath , [
661+ '--experimental-config-file' ,
662+ fixtures . path ( 'rc/empty-object.json' ) ,
663+ '-e' , 'process.exit(0)' ,
664+ ] ) ;
665+ assert . strictEqual ( result . code , 0 ) ;
666+ } ) ;
625667} ) ;
0 commit comments