@@ -7,26 +7,27 @@ const parseYamlFromFile = (filePath) => {
77 return YAML . parse ( schemaYaml , { prettyErrors : true } ) ;
88} ;
99
10- describe ( "v1.0" , ( ) => {
11- describe ( "Pass" , ( ) => {
12- readdirSync ( `./tests/v1.0/pass` , { withFileTypes : true } )
10+ function runTestSuite ( version , suite ) {
11+ const schema = `./schemas/${ version } /schema.yaml` ;
12+ describe ( suite , ( ) => {
13+ readdirSync ( `./tests/${ version } /${ suite } ` , { withFileTypes : true } )
1314 . filter ( ( entry ) => entry . isFile ( ) && / \. y a m l $ / . test ( entry . name ) )
1415 . forEach ( ( entry ) => {
1516 test ( entry . name , async ( ) => {
16- const instance = parseYamlFromFile ( `./tests/v1.0/pass/${ entry . name } ` ) ;
17- await expect ( instance ) . to . matchJsonSchema ( "./schemas/v1.0/schema.yaml" ) ;
17+ const instance = parseYamlFromFile ( `./tests/${ version } /${ suite } /${ entry . name } ` ) ;
18+ if ( suite === "pass" ) {
19+ await expect ( instance ) . to . matchJsonSchema ( schema ) ;
20+ } else {
21+ await expect ( instance ) . to . not . matchJsonSchema ( schema ) ;
22+ }
1823 } ) ;
1924 } ) ;
2025 } ) ;
26+ }
2127
22- describe ( "Fail" , ( ) => {
23- readdirSync ( `./tests/v1.0/fail` , { withFileTypes : true } )
24- . filter ( ( entry ) => entry . isFile ( ) && / \. y a m l $ / . test ( entry . name ) )
25- . forEach ( ( entry ) => {
26- test ( entry . name , async ( ) => {
27- const instance = parseYamlFromFile ( `./tests/v1.0/fail/${ entry . name } ` ) ;
28- await expect ( instance ) . to . not . matchJsonSchema ( "./schemas/v1.0/schema.yaml" ) ;
29- } ) ;
30- } ) ;
31- } ) ;
28+ const version = "v1.0" ;
29+
30+ describe ( version , ( ) => {
31+ runTestSuite ( version , "pass" ) ;
32+ runTestSuite ( version , "fail" ) ;
3233} ) ;
0 commit comments