@@ -27,6 +27,19 @@ describe("parseTemplateSpec", () => {
2727 test ( "rejects a non-object" , ( ) => {
2828 expect ( ( ) => parseTemplateSpec ( null ) ) . toThrow ( ) ;
2929 } ) ;
30+ test ( "rejects an unknown format" , ( ) => {
31+ expect ( ( ) => parseTemplateSpec ( {
32+ generators : [ { name : "x" , template : "t" , scope : "perModel" , outputPattern : "x" , format : "xml-typo" } ] ,
33+ } ) ) . toThrow ( / f o r m a t / i) ;
34+ } ) ;
35+ test ( "accepts every schema-enumerated format" , ( ) => {
36+ for ( const fmt of [ "text" , "html" , "xml" , "csv" , "json" , "markdown" , "spreadsheet" ] as const ) {
37+ const spec = parseTemplateSpec ( {
38+ generators : [ { name : "x" , template : "t" , scope : "perModel" , outputPattern : "x" , format : fmt } ] ,
39+ } ) ;
40+ expect ( spec . generators [ 0 ] ! . format ) . toBe ( fmt ) ;
41+ }
42+ } ) ;
3043} ) ;
3144
3245describe ( "templateSpecToGenerators" , ( ) => {
@@ -42,4 +55,13 @@ describe("schema ↔ parser drift", () => {
4255 . properties . generators . items . properties . scope . enum ;
4356 expect ( scopeEnum ) . toEqual ( [ "perEntity" , "perPackage" , "perModel" ] ) ;
4457 } ) ;
58+ test ( "schema enumerates the same formats the parser accepts" , ( ) => {
59+ const formatEnum = ( schema as { properties : { generators : { items : { properties : { format : { enum : string [ ] } } } } } } )
60+ . properties . generators . items . properties . format . enum ;
61+ for ( const fmt of formatEnum ) {
62+ expect ( ( ) => parseTemplateSpec ( {
63+ generators : [ { name : "x" , template : "t" , scope : "perModel" , outputPattern : "x" , format : fmt } ] ,
64+ } ) ) . not . toThrow ( ) ;
65+ }
66+ } ) ;
4567} ) ;
0 commit comments