@@ -676,20 +676,62 @@ describe('namespace-scoped options', () => {
676676 } ) ;
677677} ) ;
678678
679- test ( 'should reject config with schema validation errors' , async ( ) => {
680- const result = await spawnPromisified ( process . execPath , [
681- '--experimental-config-file' ,
682- fixtures . path ( 'rc/invalid-schema-type.json' ) ,
683- '-p' , '"Hello"' ,
684- ] ) ;
685- assert . match ( result . stderr , / I n v a l i d c o n f i g u r a t i o n / ) ;
686- assert . strictEqual ( result . code , 9 ) ;
687- } ) ;
679+ describe ( 'JSON Schema validation' , ( ) => {
680+ test ( 'rejects boolean option with string value' , async ( ) => {
681+ const result = await spawnPromisified ( process . execPath , [
682+ '--experimental-config-file' ,
683+ fixtures . path ( 'rc/invalid-schema-type.json' ) ,
684+ '-p' , '"Hello"' ,
685+ ] ) ;
686+ assert . match ( result . stderr , / I n v a l i d c o n f i g u r a t i o n / ) ;
687+ assert . strictEqual ( result . code , 9 ) ;
688+ } ) ;
688689
689- test ( 'process.versions.ata should be defined' , async ( ) => {
690- const result = await spawnPromisified ( process . execPath , [
691- '-p' , 'process.versions.ata' ,
692- ] ) ;
693- assert . match ( result . stdout , / \d + \. \d + \. \d + / ) ;
694- assert . strictEqual ( result . code , 0 ) ;
690+ test ( 'rejects number option with string value' , async ( ) => {
691+ const result = await spawnPromisified ( process . execPath , [
692+ '--experimental-config-file' ,
693+ fixtures . path ( 'rc/invalid-schema-number-as-string.json' ) ,
694+ '-p' , '"Hello"' ,
695+ ] ) ;
696+ assert . match ( result . stderr , / I n v a l i d c o n f i g u r a t i o n / ) ;
697+ assert . strictEqual ( result . code , 9 ) ;
698+ } ) ;
699+
700+ test ( 'rejects array option with boolean value' , async ( ) => {
701+ const result = await spawnPromisified ( process . execPath , [
702+ '--experimental-config-file' ,
703+ fixtures . path ( 'rc/invalid-schema-array-as-bool.json' ) ,
704+ '-p' , '"Hello"' ,
705+ ] ) ;
706+ assert . match ( result . stderr , / I n v a l i d c o n f i g u r a t i o n / ) ;
707+ assert . strictEqual ( result . code , 9 ) ;
708+ } ) ;
709+
710+ test ( 'rejects array with wrong item type' , async ( ) => {
711+ const result = await spawnPromisified ( process . execPath , [
712+ '--experimental-config-file' ,
713+ fixtures . path ( 'rc/invalid-schema-nested-type.json' ) ,
714+ '-p' , '"Hello"' ,
715+ ] ) ;
716+ assert . match ( result . stderr , / I n v a l i d c o n f i g u r a t i o n / ) ;
717+ assert . strictEqual ( result . code , 9 ) ;
718+ } ) ;
719+
720+ test ( 'accepts valid config with mixed types' , async ( ) => {
721+ const result = await spawnPromisified ( process . execPath , [
722+ '--experimental-config-file' ,
723+ fixtures . path ( 'rc/valid-schema-all-types.json' ) ,
724+ '-e' , 'process.exit(0)' ,
725+ ] ) ;
726+ assert . strictEqual ( result . code , 0 ) ;
727+ } ) ;
728+
729+ test ( 'accepts empty object config' , async ( ) => {
730+ const result = await spawnPromisified ( process . execPath , [
731+ '--experimental-config-file' ,
732+ fixtures . path ( 'rc/empty-object.json' ) ,
733+ '-e' , 'process.exit(0)' ,
734+ ] ) ;
735+ assert . strictEqual ( result . code , 0 ) ;
736+ } ) ;
695737} ) ;
0 commit comments