@@ -6,18 +6,18 @@ import { remove, readFileSync } from 'fs-extra';
66describe ( '/test/index.test.ts' , ( ) => {
77 it ( 'test generate ts interface' , async ( ) => {
88 const compiler = new Compiler ( {
9- path : [ 'test/fixtures' ] ,
9+ path : [ 'test/fixtures/common ' ] ,
1010 target : [ '.proto' ] ,
1111 ignore : [ 'node_modules' , 'dist' ] ,
1212 } ) ;
1313
1414 compiler . compile ( ) ;
1515
16- expect ( existsSync ( join ( __dirname , './fixtures/hero.ts' ) ) ) . toBeTruthy ( ) ;
17- expect ( existsSync ( join ( __dirname , './fixtures/helloworld.ts' ) ) ) . toBeTruthy ( ) ;
18- expect ( existsSync ( join ( __dirname , './fixtures/math.ts' ) ) ) . toBeTruthy ( ) ;
16+ expect ( existsSync ( join ( __dirname , './fixtures/common/ hero.ts' ) ) ) . toBeTruthy ( ) ;
17+ expect ( existsSync ( join ( __dirname , './fixtures/common/ helloworld.ts' ) ) ) . toBeTruthy ( ) ;
18+ expect ( existsSync ( join ( __dirname , './fixtures/common/ math.ts' ) ) ) . toBeTruthy ( ) ;
1919
20- const content = readFileSync ( join ( __dirname , './fixtures/math.ts' ) , 'utf8' ) ;
20+ const content = readFileSync ( join ( __dirname , './fixtures/common/ math.ts' ) , 'utf8' ) ;
2121 expect ( content . includes ( 'add(data: AddArgs): Promise<Num>;' ) ) . toBeTruthy ( ) ;
2222 expect ( content . includes ( 'addMore(data: AddArgs): Promise<void>;' ) ) . toBeTruthy ( ) ;
2323 expect ( content . includes ( 'sumMany(data: AddArgs): Promise<void>;' ) ) . toBeTruthy ( ) ;
@@ -32,26 +32,44 @@ describe('/test/index.test.ts', () => {
3232 expect ( content . includes ( 'addMany(options?: grpc.IClientOptions): grpc.IClientWritableStreamService<AddArgs, Num>;' ) ) . toBeTruthy ( ) ;
3333 expect ( content . includes ( 'addEmpty(options?: grpc.IClientOptions): grpc.IClientUnaryService<any, any>;' ) ) . toBeTruthy ( ) ;
3434
35- await remove ( join ( __dirname , './fixtures/hero.ts' ) ) ;
36- await remove ( join ( __dirname , './fixtures/helloworld.ts' ) ) ;
37- await remove ( join ( __dirname , './fixtures/math.ts' ) ) ;
38- await remove ( join ( __dirname , './fixtures/hello_stream.ts' ) ) ;
35+ await remove ( join ( __dirname , './fixtures/common/ hero.ts' ) ) ;
36+ await remove ( join ( __dirname , './fixtures/common/ helloworld.ts' ) ) ;
37+ await remove ( join ( __dirname , './fixtures/common/ math.ts' ) ) ;
38+ await remove ( join ( __dirname , './fixtures/common/ hello_stream.ts' ) ) ;
3939 } ) ;
4040
4141 it ( 'test generate ts interface to specified directory' , async ( ) => {
4242 const compiler = new Compiler ( {
43- path : [ 'test/fixtures' ] ,
43+ path : [ 'test/fixtures/common ' ] ,
4444 target : [ '.proto' ] ,
4545 ignore : [ 'node_modules' , 'dist' ] ,
46- output : 'test/fixtures/domain'
46+ output : 'test/fixtures/common/ domain'
4747 } ) ;
4848
4949 compiler . compile ( ) ;
5050
51- expect ( existsSync ( join ( __dirname , './fixtures/domain/hero.ts' ) ) ) . toBeTruthy ( ) ;
52- expect ( existsSync ( join ( __dirname , './fixtures/domain/helloworld.ts' ) ) ) . toBeTruthy ( ) ;
53- expect ( existsSync ( join ( __dirname , './fixtures/domain/math.ts' ) ) ) . toBeTruthy ( ) ;
51+ expect ( existsSync ( join ( __dirname , './fixtures/common/ domain/hero.ts' ) ) ) . toBeTruthy ( ) ;
52+ expect ( existsSync ( join ( __dirname , './fixtures/common/ domain/helloworld.ts' ) ) ) . toBeTruthy ( ) ;
53+ expect ( existsSync ( join ( __dirname , './fixtures/common/ domain/math.ts' ) ) ) . toBeTruthy ( ) ;
5454
55- await remove ( join ( __dirname , './fixtures/domain' ) ) ;
55+ await remove ( join ( __dirname , './fixtures/common/domain' ) ) ;
56+ } ) ;
57+
58+ it ( 'test generate ts interface keep case' , async ( ) => {
59+ const compiler = new Compiler ( {
60+ path : [ 'test/fixtures/keep_case' ] ,
61+ target : [ '.proto' ] ,
62+ ignore : [ 'node_modules' , 'dist' ] ,
63+ output : 'test/fixtures/keep_case/domain' ,
64+ keepCase : true ,
65+ } ) ;
66+
67+ compiler . compile ( ) ;
68+
69+ expect ( existsSync ( join ( __dirname , './fixtures/keep_case/domain/helloworld_keep_case.ts' ) ) ) . toBeTruthy ( ) ;
70+ const content = readFileSync ( join ( __dirname , './fixtures/keep_case/domain/helloworld_keep_case.ts' ) , 'utf8' ) ;
71+ expect ( content . includes ( 'key_filed' ) ) . toBeTruthy ( ) ;
72+
73+ await remove ( join ( __dirname , './fixtures/keep_case/domain' ) ) ;
5674 } ) ;
5775} ) ;
0 commit comments