@@ -9,11 +9,15 @@ const ajv = new Ajv();
99
1010const base = "test/programs/" ;
1111
12- export function assertSchema ( group : string , name : string , type : string , settings ? : any , compilerOptions ?: CompilerOptions ) {
12+ export function assertSchema ( group : string , name : string , type : string , settings : any = { } , compilerOptions ?: CompilerOptions ) {
1313 it ( group + " should create correct schema" , function ( ) {
14- if ( ! settings ) {
15- settings = TJS . getDefaultArgs ( ) ;
16- settings . generateRequired = true ;
14+ const defaults = TJS . getDefaultArgs ( ) ;
15+ defaults . generateRequired = true ;
16+
17+ for ( let pref in defaults ) {
18+ if ( ! ( pref in settings ) ) {
19+ settings [ pref ] = defaults [ pref ] ;
20+ }
1721 }
1822
1923 const actual = TJS . generateSchema ( TJS . getProgramFromFiles ( [ resolve ( base + group + "/" + name ) ] , compilerOptions ) , type , settings ) ;
@@ -37,9 +41,9 @@ describe("schema", function () {
3741 assertSchema ( "interface-single" , "main.ts" , "MyObject" ) ;
3842 assertSchema ( "interface-multi" , "main.ts" , "MyObject" ) ;
3943
40- let settings = TJS . getDefaultArgs ( ) ;
41- settings . useRootRef = true ;
42- assertSchema ( "interface-recursion" , "main.ts" , "MyObject" , settings ) ; // this sample needs rootRef
44+ assertSchema ( "interface-recursion" , "main.ts" , "MyObject" , {
45+ useRootRef : true
46+ } ) ;
4347
4448 assertSchema ( "module-interface-single" , "main.ts" , "MyObject" ) ;
4549
@@ -62,7 +66,10 @@ describe("schema", function () {
6266 assertSchema ( "type-union" , "main.ts" , "MyObject" ) ;
6367 assertSchema ( "type-intersection" , "main.ts" , "MyObject" ) ;
6468
65- assertSchema ( "type-aliases" , "main.ts" , "MyString" ) ;
69+ assertSchema ( "type-alias-single" , "main.ts" , "MyString" ) ;
70+ assertSchema ( "type-aliases" , "main.ts" , "MyObject" , {
71+ useTypeAliasRef : true
72+ } ) ;
6673 assertSchema ( "type-aliases-fixed-size-array" , "main.ts" , "MyFixedSizeArray" ) ;
6774 assertSchema ( "type-aliases-multitype-array" , "main.ts" , "MyArray" ) ;
6875 assertSchema ( "type-anonymous" , "main.ts" , "MyObject" ) ;
0 commit comments