@@ -2,15 +2,18 @@ import fs from "fs";
22import path from "path" ;
33import { execSync } from "child_process" ;
44
5+ const schemas = fs . readdirSync ( path . join ( __dirname , "specs" ) ) ;
6+
57// simple snapshot tests with valid schemas to make sure it can generally parse & generate output
68describe ( "cli" , ( ) => {
7- [ "stripe" , "manifold" , "petstore" ] . forEach ( ( file ) => {
8- it ( `reads ${ file } spec (v2) from file` , ( ) => {
9- execSync ( `../../pkg/bin/cli.js specs/${ file } .yaml -o generated/${ file } .ts` , {
9+ schemas . forEach ( ( schema ) => {
10+ const output = schema . replace ( / \y a ? m l $ / i, "ts" ) ;
11+ it ( `reads ${ schema } spec (v2) from file` , ( ) => {
12+ execSync ( `../../pkg/bin/cli.js specs/${ schema } -o generated/${ output } ` , {
1013 cwd : __dirname ,
1114 } ) ;
12- const expected = fs . readFileSync ( path . join ( __dirname , "expected" , ` ${ file } .ts` ) , "utf8" ) ;
13- const generated = fs . readFileSync ( path . join ( __dirname , "generated" , ` ${ file } .ts` ) , "utf8" ) ;
15+ const expected = fs . readFileSync ( path . join ( __dirname , "expected" , output ) , "utf8" ) ;
16+ const generated = fs . readFileSync ( path . join ( __dirname , "generated" , output ) , "utf8" ) ;
1417 expect ( generated ) . toBe ( expected ) ;
1518 } ) ;
1619 } ) ;
0 commit comments