@@ -9,22 +9,23 @@ import {
99import { before } from '../compiler-plugin' ;
1010
1111describe ( '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+
1221 test ( 'should ignore if file name is not match' , ( ) => {
1322 // 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- } ;
2223 const filename = 'not-match.ts' ;
23- const fakeProgram = ts . createProgram ( [ filename ] , options ) ;
24+ const fakeProgram = ts . createProgram ( [ filename ] , compilerOptions ) ;
2425
2526 // when
2627 const result = ts . transpileModule ( needResponseBodyServiceCode , {
27- compilerOptions : options ,
28+ compilerOptions,
2829 fileName : filename ,
2930 transformers : { before : [ before ( { } , fakeProgram ) ] } ,
3031 } ) ;
@@ -35,20 +36,12 @@ describe('HttpInterfaceVisitor', () => {
3536
3637 test ( 'should ignore if return type is not a class' , ( ) => {
3738 // 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- } ;
4639 const filename = 'text.service.ts' ;
47- const fakeProgram = ts . createProgram ( [ filename ] , options ) ;
40+ const fakeProgram = ts . createProgram ( [ filename ] , compilerOptions ) ;
4841
4942 // when
5043 const result = ts . transpileModule ( returnStringServiceCode , {
51- compilerOptions : options ,
44+ compilerOptions,
5245 fileName : filename ,
5346 transformers : {
5447 before : [ before ( undefined , fakeProgram ) ] ,
@@ -61,20 +54,12 @@ describe('HttpInterfaceVisitor', () => {
6154
6255 test ( 'should ignore if method has ResponseBody decorator' , ( ) => {
6356 // 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- } ;
7257 const filename = 'text.service.ts' ;
73- const fakeProgram = ts . createProgram ( [ filename ] , options ) ;
58+ const fakeProgram = ts . createProgram ( [ filename ] , compilerOptions ) ;
7459
7560 // when
7661 const result = ts . transpileModule ( hasResponseBodyServiceCode , {
77- compilerOptions : options ,
62+ compilerOptions,
7863 fileName : filename ,
7964 transformers : { before : [ before ( { } , fakeProgram ) ] } ,
8065 } ) ;
@@ -85,20 +70,12 @@ describe('HttpInterfaceVisitor', () => {
8570
8671 test ( 'should ignore if return type if not a promise ' , ( ) => {
8772 // 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- } ;
9673 const filename = 'text.service.ts' ;
97- const fakeProgram = ts . createProgram ( [ filename ] , options ) ;
74+ const fakeProgram = ts . createProgram ( [ filename ] , compilerOptions ) ;
9875
9976 // when
10077 const result = ts . transpileModule ( notPromiseServiceCode , {
101- compilerOptions : options ,
78+ compilerOptions,
10279 fileName : filename ,
10380 transformers : { before : [ before ( { } , fakeProgram ) ] } ,
10481 } ) ;
@@ -109,20 +86,12 @@ describe('HttpInterfaceVisitor', () => {
10986
11087 test ( 'should override plugin suffix option' , ( ) => {
11188 // 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- } ;
12089 const filename = '.custom.ts' ;
121- const fakeProgram = ts . createProgram ( [ filename ] , options ) ;
90+ const fakeProgram = ts . createProgram ( [ filename ] , compilerOptions ) ;
12291
12392 // when
12493 const result = ts . transpileModule ( needResponseBodyServiceCode , {
125- compilerOptions : options ,
94+ compilerOptions,
12695 fileName : filename ,
12796 transformers : {
12897 before : [
0 commit comments