@@ -9,22 +9,23 @@ import {
9
9
import { before } from '../compiler-plugin' ;
10
10
11
11
describe ( 'HttpInterfaceVisitor' , ( ) => {
12
+ const compilerOptions = {
13
+ module : ts . ModuleKind . ES2020 ,
14
+ target : ts . ScriptTarget . ES2020 ,
15
+ newLine : ts . NewLineKind . LineFeed ,
16
+ noEmitHelpers : true ,
17
+ experimentalDecorators : true ,
18
+ strict : true ,
19
+ } ;
20
+
12
21
test ( 'should ignore if file name is not match' , ( ) => {
13
22
// given
14
- const options : ts . CompilerOptions = {
15
- module : ts . ModuleKind . ES2020 ,
16
- target : ts . ScriptTarget . ES2020 ,
17
- newLine : ts . NewLineKind . LineFeed ,
18
- noEmitHelpers : true ,
19
- experimentalDecorators : true ,
20
- strict : true ,
21
- } ;
22
23
const filename = 'not-match.ts' ;
23
- const fakeProgram = ts . createProgram ( [ filename ] , options ) ;
24
+ const fakeProgram = ts . createProgram ( [ filename ] , compilerOptions ) ;
24
25
25
26
// when
26
27
const result = ts . transpileModule ( needResponseBodyServiceCode , {
27
- compilerOptions : options ,
28
+ compilerOptions,
28
29
fileName : filename ,
29
30
transformers : { before : [ before ( { } , fakeProgram ) ] } ,
30
31
} ) ;
@@ -35,20 +36,12 @@ describe('HttpInterfaceVisitor', () => {
35
36
36
37
test ( 'should ignore if return type is not a class' , ( ) => {
37
38
// given
38
- const options : ts . CompilerOptions = {
39
- module : ts . ModuleKind . ES2020 ,
40
- target : ts . ScriptTarget . ES2020 ,
41
- newLine : ts . NewLineKind . LineFeed ,
42
- noEmitHelpers : true ,
43
- experimentalDecorators : true ,
44
- strict : true ,
45
- } ;
46
39
const filename = 'text.service.ts' ;
47
- const fakeProgram = ts . createProgram ( [ filename ] , options ) ;
40
+ const fakeProgram = ts . createProgram ( [ filename ] , compilerOptions ) ;
48
41
49
42
// when
50
43
const result = ts . transpileModule ( returnStringServiceCode , {
51
- compilerOptions : options ,
44
+ compilerOptions,
52
45
fileName : filename ,
53
46
transformers : {
54
47
before : [ before ( undefined , fakeProgram ) ] ,
@@ -61,20 +54,12 @@ describe('HttpInterfaceVisitor', () => {
61
54
62
55
test ( 'should ignore if method has ResponseBody decorator' , ( ) => {
63
56
// given
64
- const options : ts . CompilerOptions = {
65
- module : ts . ModuleKind . ES2020 ,
66
- target : ts . ScriptTarget . ES2020 ,
67
- newLine : ts . NewLineKind . LineFeed ,
68
- noEmitHelpers : true ,
69
- experimentalDecorators : true ,
70
- strict : true ,
71
- } ;
72
57
const filename = 'text.service.ts' ;
73
- const fakeProgram = ts . createProgram ( [ filename ] , options ) ;
58
+ const fakeProgram = ts . createProgram ( [ filename ] , compilerOptions ) ;
74
59
75
60
// when
76
61
const result = ts . transpileModule ( hasResponseBodyServiceCode , {
77
- compilerOptions : options ,
62
+ compilerOptions,
78
63
fileName : filename ,
79
64
transformers : { before : [ before ( { } , fakeProgram ) ] } ,
80
65
} ) ;
@@ -85,20 +70,12 @@ describe('HttpInterfaceVisitor', () => {
85
70
86
71
test ( 'should ignore if return type if not a promise ' , ( ) => {
87
72
// given
88
- const options : ts . CompilerOptions = {
89
- module : ts . ModuleKind . ES2020 ,
90
- target : ts . ScriptTarget . ES2020 ,
91
- newLine : ts . NewLineKind . LineFeed ,
92
- noEmitHelpers : true ,
93
- experimentalDecorators : true ,
94
- strict : true ,
95
- } ;
96
73
const filename = 'text.service.ts' ;
97
- const fakeProgram = ts . createProgram ( [ filename ] , options ) ;
74
+ const fakeProgram = ts . createProgram ( [ filename ] , compilerOptions ) ;
98
75
99
76
// when
100
77
const result = ts . transpileModule ( notPromiseServiceCode , {
101
- compilerOptions : options ,
78
+ compilerOptions,
102
79
fileName : filename ,
103
80
transformers : { before : [ before ( { } , fakeProgram ) ] } ,
104
81
} ) ;
@@ -109,20 +86,12 @@ describe('HttpInterfaceVisitor', () => {
109
86
110
87
test ( 'should override plugin suffix option' , ( ) => {
111
88
// given
112
- const options : ts . CompilerOptions = {
113
- module : ts . ModuleKind . ES2020 ,
114
- target : ts . ScriptTarget . ES2020 ,
115
- newLine : ts . NewLineKind . LineFeed ,
116
- noEmitHelpers : true ,
117
- experimentalDecorators : true ,
118
- strict : true ,
119
- } ;
120
89
const filename = '.custom.ts' ;
121
- const fakeProgram = ts . createProgram ( [ filename ] , options ) ;
90
+ const fakeProgram = ts . createProgram ( [ filename ] , compilerOptions ) ;
122
91
123
92
// when
124
93
const result = ts . transpileModule ( needResponseBodyServiceCode , {
125
- compilerOptions : options ,
94
+ compilerOptions,
126
95
fileName : filename ,
127
96
transformers : {
128
97
before : [
0 commit comments