@@ -5,29 +5,39 @@ import {
5
5
appControllerTextTranspiled
6
6
} from './fixtures/app.controller' ;
7
7
8
+ const compilerOptions : ts . CompilerOptions = {
9
+ module : ts . ModuleKind . CommonJS ,
10
+ target : ts . ScriptTarget . ESNext ,
11
+ newLine : ts . NewLineKind . LineFeed ,
12
+ noEmitHelpers : true
13
+ }
14
+
15
+ const transpileModule = ( filename , controllerText , compilerOptions , swaggerDocumentOptions = { } ) => {
16
+ const fakeProgram = ts . createProgram ( [ filename ] , compilerOptions ) ;
17
+
18
+ return ts . transpileModule ( controllerText , {
19
+ compilerOptions,
20
+ fileName : filename ,
21
+ transformers : {
22
+ before : [
23
+ before (
24
+ { ...swaggerDocumentOptions , introspectComments : true } ,
25
+ fakeProgram
26
+ )
27
+ ]
28
+ }
29
+ } )
30
+ }
31
+
8
32
describe ( 'Controller methods' , ( ) => {
9
- it ( 'should add response based on the return value' , ( ) => {
10
- const options : ts . CompilerOptions = {
11
- module : ts . ModuleKind . CommonJS ,
12
- target : ts . ScriptTarget . ESNext ,
13
- newLine : ts . NewLineKind . LineFeed ,
14
- noEmitHelpers : true
15
- } ;
16
- const filename = 'app.controller.ts' ;
17
- const fakeProgram = ts . createProgram ( [ filename ] , options ) ;
33
+ it ( 'Should generate summary property' , ( ) => {
34
+ const result = transpileModule (
35
+ 'app.controller.ts' ,
36
+ appControllerText ,
37
+ compilerOptions ,
38
+ { controllerKeyOfComment : 'summary' }
39
+ ) ;
18
40
19
- const result = ts . transpileModule ( appControllerText , {
20
- compilerOptions : options ,
21
- fileName : filename ,
22
- transformers : {
23
- before : [
24
- before (
25
- { controllerKeyOfComment : 'summary' , introspectComments : true } ,
26
- fakeProgram
27
- )
28
- ]
29
- }
30
- } ) ;
31
41
expect ( result . outputText ) . toEqual ( appControllerTextTranspiled ) ;
32
42
} ) ;
33
43
} ) ;
0 commit comments