@@ -305,10 +305,14 @@ describe('action', () => {
305305
306306 await main . run ( ) ;
307307 expect ( runSpy ) . toHaveReturned ( ) ;
308- expect ( process . exitCode ) . not . toBeDefined ( ) ;
308+ expect ( process . exitCode ) . toEqual ( 1 ) ;
309309
310- expect ( core . setFailed ) . toHaveBeenLastCalledWith (
311- 'JSON schema missing $schema key'
310+ expect ( core . error ) . toHaveBeenLastCalledWith (
311+ 'JSON schema missing $schema key' ,
312+ {
313+ title : 'JSON Schema Validation Error' ,
314+ file : '/foo/bar'
315+ }
312316 ) ;
313317 } ) ;
314318
@@ -359,6 +363,29 @@ describe('action', () => {
359363 expect ( runSpy ) . toHaveReturned ( ) ;
360364 expect ( process . exitCode ) . toEqual ( 1 ) ;
361365
366+ expect ( core . error ) . toHaveBeenCalledWith (
367+ 'Error while validating file: /foo/bar/baz/config.yml'
368+ ) ;
369+ expect ( core . error ) . toHaveBeenLastCalledWith (
370+ JSON . stringify (
371+ {
372+ instancePath : '' ,
373+ schemaPath : '#/oneOf' ,
374+ keyword : 'oneOf' ,
375+ params : {
376+ passingSchemas : [ 0 , 1 ]
377+ } ,
378+ message : 'must match exactly one schema in oneOf'
379+ } ,
380+ null ,
381+ 4
382+ ) ,
383+ {
384+ title : 'JSON Schema Validation Error' ,
385+ file : '/foo/bar/baz/config.yml'
386+ }
387+ ) ;
388+
362389 expect ( core . setOutput ) . toHaveBeenCalledTimes ( 1 ) ;
363390 expect ( core . setOutput ) . toHaveBeenLastCalledWith ( 'valid' , false ) ;
364391 } ) ;
@@ -447,14 +474,36 @@ describe('action', () => {
447474 } ) ;
448475
449476 it ( 'which are invalid' , async ( ) => {
450- mockGetBooleanInput ( { 'fail-on-invalid' : false } ) ;
477+ mockGetBooleanInput ( { 'fail-on-invalid' : true } ) ;
451478
452479 vi . mocked ( fs . readFile ) . mockResolvedValueOnce ( invalidSchemaContents ) ;
453480
454481 await main . run ( ) ;
455482 expect ( runSpy ) . toHaveReturned ( ) ;
456- expect ( process . exitCode ) . not . toBeDefined ( ) ;
483+ expect ( process . exitCode ) . toEqual ( 1 ) ;
457484
485+ expect ( core . error ) . toHaveBeenCalledWith (
486+ 'Error while validating file: /foo/bar/baz/config.yml'
487+ ) ;
488+ expect ( core . error ) . toHaveBeenLastCalledWith (
489+ JSON . stringify (
490+ {
491+ instancePath : '/properties/foobar/minLength' ,
492+ schemaPath : '#/definitions/nonNegativeInteger/type' ,
493+ keyword : 'type' ,
494+ params : {
495+ type : 'integer'
496+ } ,
497+ message : 'must be integer'
498+ } ,
499+ null ,
500+ 4
501+ ) ,
502+ {
503+ title : 'JSON Schema Validation Error' ,
504+ file : '/foo/bar/baz/config.yml'
505+ }
506+ ) ;
458507 expect ( core . setOutput ) . toHaveBeenCalledTimes ( 1 ) ;
459508 expect ( core . setOutput ) . toHaveBeenLastCalledWith ( 'valid' , false ) ;
460509 } ) ;
@@ -482,10 +531,14 @@ describe('action', () => {
482531
483532 await main . run ( ) ;
484533 expect ( runSpy ) . toHaveReturned ( ) ;
485- expect ( process . exitCode ) . not . toBeDefined ( ) ;
486-
487- expect ( core . setFailed ) . toHaveBeenLastCalledWith (
488- 'JSON schema missing $schema key'
534+ expect ( process . exitCode ) . toEqual ( 1 ) ;
535+
536+ expect ( core . error ) . toHaveBeenLastCalledWith (
537+ 'JSON schema missing $schema key' ,
538+ {
539+ title : 'JSON Schema Validation Error' ,
540+ file : '/foo/bar/baz/config.yml'
541+ }
489542 ) ;
490543 } ) ;
491544 } ) ;
0 commit comments