@@ -32,8 +32,8 @@ it('Api', done => {
32
32
33
33
describe ( 'Generation tests using all-types.json' , ( ) => {
34
34
it ( 'RefEnum model' , done => {
35
- const refString = gen . models . get ( 'RefEnum' ) ;
36
- const ts = gen . templates . apply ( 'model' , refString ) ;
35
+ const ref = gen . models . get ( 'RefEnum' ) ;
36
+ const ts = gen . templates . apply ( 'model' , ref ) ;
37
37
const parser = new TypescriptParser ( ) ;
38
38
parser . parseSource ( ts ) . then ( ast => {
39
39
expect ( ast . imports . length ) . toBe ( 0 ) ;
@@ -49,6 +49,24 @@ describe('Generation tests using all-types.json', () => {
49
49
} ) ;
50
50
} ) ;
51
51
52
+ it ( 'RefIntEnum model' , done => {
53
+ const ref = gen . models . get ( 'RefIntEnum' ) ;
54
+ const ts = gen . templates . apply ( 'model' , ref ) ;
55
+ const parser = new TypescriptParser ( ) ;
56
+ parser . parseSource ( ts ) . then ( ast => {
57
+ expect ( ast . imports . length ) . toBe ( 0 ) ;
58
+ expect ( ast . declarations . length ) . toBe ( 1 ) ;
59
+ expect ( ast . declarations [ 0 ] ) . toEqual ( jasmine . any ( EnumDeclaration ) ) ;
60
+ const decl = ast . declarations [ 0 ] as EnumDeclaration ;
61
+ expect ( decl . name ) . toBe ( 'RefIntEnum' ) ;
62
+ expect ( decl . members . length ) . toBe ( 3 ) ;
63
+ expect ( decl . members [ 0 ] ) . toBe ( '$100' ) ;
64
+ expect ( decl . members [ 1 ] ) . toBe ( '$200' ) ;
65
+ expect ( decl . members [ 2 ] ) . toBe ( '$300' ) ;
66
+ done ( ) ;
67
+ } ) ;
68
+ } ) ;
69
+
52
70
it ( 'a.b.RefObject model' , done => {
53
71
const refObject = gen . models . get ( 'a.b.RefObject' ) ;
54
72
const ts = gen . templates . apply ( 'model' , refObject ) ;
@@ -96,7 +114,7 @@ describe('Generation tests using all-types.json', () => {
96
114
const decl = ast . declarations [ 0 ] as TypeAliasDeclaration ;
97
115
expect ( decl . name ) . toBe ( 'Union' ) ;
98
116
const text = ts . substring ( decl . start || 0 , decl . end || ts . length ) ;
99
- expect ( text ) . toBe ( 'export type Union = { [key: string]: any } | RefEnum | Container;' ) ;
117
+ expect ( text ) . toBe ( 'export type Union = { [key: string]: any } | RefEnum | RefIntEnum | Container;' ) ;
100
118
done ( ) ;
101
119
} ) ;
102
120
} ) ;
@@ -236,7 +254,7 @@ describe('Generation tests using all-types.json', () => {
236
254
expect ( ast . declarations [ 0 ] ) . toEqual ( jasmine . any ( InterfaceDeclaration ) ) ;
237
255
const decl = ast . declarations [ 0 ] as InterfaceDeclaration ;
238
256
expect ( decl . name ) . toBe ( 'Container' ) ;
239
- expect ( decl . properties . length ) . toBe ( 19 ) ;
257
+ expect ( decl . properties . length ) . toBe ( 21 ) ;
240
258
241
259
// Assert the simple types
242
260
function assertProperty ( name : string , type : string , required = false ) {
@@ -267,6 +285,8 @@ describe('Generation tests using all-types.json', () => {
267
285
assertProperty ( 'nestedObject' , '{ \'p1\': string, \'p2\': number, ' +
268
286
'\'deeper\': { \'d1\': ABRefObject, \'d2\': string | Array<ABRefObject> | number } }' ) ;
269
287
assertProperty ( 'dynamic' , '{ [key: string]: XYRefObject }' ) ;
288
+ assertProperty ( 'stringEnumProp' , '\'a\' | \'b\' | \'c\'' ) ;
289
+ assertProperty ( 'intEnumProp' , '1 | 2 | 3' ) ;
270
290
271
291
done ( ) ;
272
292
} ) ;
0 commit comments