@@ -6,18 +6,18 @@ import { remove, readFileSync } from 'fs-extra';
6
6
describe ( '/test/index.test.ts' , ( ) => {
7
7
it ( 'test generate ts interface' , async ( ) => {
8
8
const compiler = new Compiler ( {
9
- path : [ 'test/fixtures' ] ,
9
+ path : [ 'test/fixtures/common ' ] ,
10
10
target : [ '.proto' ] ,
11
11
ignore : [ 'node_modules' , 'dist' ] ,
12
12
} ) ;
13
13
14
14
compiler . compile ( ) ;
15
15
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 ( ) ;
19
19
20
- const content = readFileSync ( join ( __dirname , './fixtures/math.ts' ) , 'utf8' ) ;
20
+ const content = readFileSync ( join ( __dirname , './fixtures/common/ math.ts' ) , 'utf8' ) ;
21
21
expect ( content . includes ( 'add(data: AddArgs): Promise<Num>;' ) ) . toBeTruthy ( ) ;
22
22
expect ( content . includes ( 'addMore(data: AddArgs): Promise<void>;' ) ) . toBeTruthy ( ) ;
23
23
expect ( content . includes ( 'sumMany(data: AddArgs): Promise<void>;' ) ) . toBeTruthy ( ) ;
@@ -32,26 +32,44 @@ describe('/test/index.test.ts', () => {
32
32
expect ( content . includes ( 'addMany(options?: grpc.IClientOptions): grpc.IClientWritableStreamService<AddArgs, Num>;' ) ) . toBeTruthy ( ) ;
33
33
expect ( content . includes ( 'addEmpty(options?: grpc.IClientOptions): grpc.IClientUnaryService<any, any>;' ) ) . toBeTruthy ( ) ;
34
34
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' ) ) ;
39
39
} ) ;
40
40
41
41
it ( 'test generate ts interface to specified directory' , async ( ) => {
42
42
const compiler = new Compiler ( {
43
- path : [ 'test/fixtures' ] ,
43
+ path : [ 'test/fixtures/common ' ] ,
44
44
target : [ '.proto' ] ,
45
45
ignore : [ 'node_modules' , 'dist' ] ,
46
- output : 'test/fixtures/domain'
46
+ output : 'test/fixtures/common/ domain'
47
47
} ) ;
48
48
49
49
compiler . compile ( ) ;
50
50
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 ( ) ;
54
54
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' ) ) ;
56
74
} ) ;
57
75
} ) ;
0 commit comments