@@ -23,25 +23,27 @@ SWSchemaValidator.prepareSchemas();
23
23
const examplePath = "../../../examples" ;
24
24
25
25
describe ( `Verify every example in the repository` , ( ) => {
26
- fs . readdirSync ( path . join ( __dirname , examplePath ) , {
27
- encoding : SWSchemaValidator . defaultEncoding ,
28
- recursive : false ,
29
- withFileTypes : true ,
30
- } ) . forEach ( ( file ) => {
31
- if ( file . isFile ( ) && file . name . endsWith ( ".yaml" ) ) {
32
- test ( `Example ${ file . name } ` , ( ) => {
33
- const workflow = SWSchemaValidator . toJSON (
34
- path . join ( __dirname , `${ examplePath } /${ file . name } ` )
35
- ) ;
36
- const results = SWSchemaValidator . validateSchema ( workflow ) ;
37
- if ( results ?. errors != null ) {
38
- console . warn (
39
- `Schema validation on ${ file . name } failed with: ` ,
40
- JSON . stringify ( results . errors , null , 2 )
41
- ) ;
42
- }
43
- expect ( results ?. valid ) . toBeTruthy ( ) ;
44
- } ) ;
26
+ const examples = fs
27
+ . readdirSync ( path . join ( __dirname , examplePath ) , {
28
+ encoding : SWSchemaValidator . defaultEncoding ,
29
+ recursive : false ,
30
+ withFileTypes : true ,
31
+ } )
32
+ . filter ( ( file ) => file . isFile ( ) )
33
+ . filter ( ( file ) => file . name . endsWith ( ".yaml" ) )
34
+ . map ( ( file ) => file . name ) ;
35
+
36
+ test . each ( examples ) ( "Example %s" , ( file ) => {
37
+ const workflow = SWSchemaValidator . toJSON (
38
+ path . join ( __dirname , `${ examplePath } /${ file } ` )
39
+ ) ;
40
+ const results = SWSchemaValidator . validateSchema ( workflow ) ;
41
+ if ( results ?. errors != null ) {
42
+ console . warn (
43
+ `Schema validation on ${ file } failed with: ` ,
44
+ JSON . stringify ( results . errors , null , 2 )
45
+ ) ;
45
46
}
47
+ expect ( results ?. valid ) . toBeTruthy ( ) ;
46
48
} ) ;
47
49
} ) ;
0 commit comments