@@ -10,20 +10,14 @@ import { b64Decode } from "./fetch.pb";
10
10
11
11
describe ( "test static functions" , ( ) => {
12
12
it ( "unary request" , async ( ) => {
13
- const result = await increment (
14
- { counter : 199 } ,
15
- { pathPrefix : "http://localhost:8081" }
16
- ) ;
13
+ const result = await increment ( { counter : 199 } ) ;
17
14
18
15
expect ( result . result ) . to . equal ( 200 ) ;
19
16
} ) ;
20
17
21
18
it ( "failing unary request" , async ( ) => {
22
19
try {
23
- await failingIncrement (
24
- { counter : 199 } ,
25
- { pathPrefix : "http://localhost:8081" }
26
- ) ;
20
+ await failingIncrement ( { counter : 199 } ) ;
27
21
expect . fail ( "expected call to throw" ) ;
28
22
} catch ( e ) {
29
23
expect ( e ) . to . have . property ( "message" , "this increment does not work" ) ;
@@ -33,10 +27,8 @@ describe("test static functions", () => {
33
27
34
28
it ( "streaming request" , async ( ) => {
35
29
const response = [ ] as number [ ] ;
36
- await streamingIncrements (
37
- { counter : 1 } ,
38
- ( resp ) => response . push ( resp . result ) ,
39
- { pathPrefix : "http://localhost:8081" }
30
+ await streamingIncrements ( { counter : 1 } , ( resp ) =>
31
+ response . push ( resp . result )
40
32
) ;
41
33
expect ( response ) . to . deep . equal ( [ 2 , 3 , 4 , 5 , 6 ] ) ;
42
34
} ) ;
@@ -67,65 +59,67 @@ describe("test with client class", () => {
67
59
68
60
it ( "http get check request" , async ( ) => {
69
61
const req = { numToIncrease : 10 } as HttpGetRequest ;
70
- const result = await client . httpGet ( req , {
71
- pathPrefix : "http://localhost:8081" ,
72
- } ) ;
62
+ const result = await client . httpGet ( req ) ;
73
63
expect ( result . result ) . to . equal ( 11 ) ;
74
64
} ) ;
75
65
76
66
it ( "http post body check request with nested body path" , async ( ) => {
77
- const result = await client . httpPostWithNestedBodyPath (
78
- { a : 10 , req : { b : 15 } , c : 0 } ,
79
- { pathPrefix : "http://localhost:8081" }
80
- ) ;
67
+ const result = await client . httpPostWithNestedBodyPath ( {
68
+ a : 10 ,
69
+ req : { b : 15 } ,
70
+ c : 0 ,
71
+ } ) ;
81
72
expect ( result . postResult ) . to . equal ( 25 ) ;
82
73
} ) ;
83
74
84
75
it ( "http post body check request with star in path" , async ( ) => {
85
- const result = await client . httpPostWithStarBodyPath (
86
- { a : 10 , req : { b : 15 } , c : 23 } ,
87
- { pathPrefix : "http://localhost:8081" }
88
- ) ;
76
+ const result = await client . httpPostWithStarBodyPath ( {
77
+ a : 10 ,
78
+ req : { b : 15 } ,
79
+ c : 23 ,
80
+ } ) ;
89
81
expect ( result . postResult ) . to . equal ( 48 ) ;
90
82
} ) ;
91
83
92
84
it ( "able to communicate with external message reference without package defined" , async ( ) => {
93
- const result = await client . externalMessage (
94
- { content : "hello" } ,
95
- { pathPrefix : "http://localhost:8081" }
96
- ) ;
85
+ const result = await client . externalMessage ( { content : "hello" } ) ;
97
86
expect ( result . result ) . to . equal ( "hello!!" ) ;
98
87
} ) ;
99
88
100
89
it ( "http patch request with star in path" , async ( ) => {
101
- const result = await client . httpPatch (
102
- { a : 10 , c : 23 } ,
103
- { pathPrefix : "http://localhost:8081" }
104
- ) ;
90
+ const result = await client . httpPatch ( { a : 10 , c : 23 } ) ;
105
91
expect ( result . patchResult ) . to . equal ( 33 ) ;
106
92
} ) ;
107
93
108
94
it ( "http delete check request" , async ( ) => {
109
- const result = await client . httpDelete (
110
- { a : 10 } ,
111
- { pathPrefix : "http://localhost:8081" }
112
- ) ;
95
+ const result = await client . httpDelete ( { a : 10 } ) ;
113
96
expect ( result ) . to . be . empty ;
114
97
} ) ;
115
98
99
+ it ( "http delete with query params" , async ( ) => {
100
+ const result = await client . httpDeleteWithParams ( {
101
+ id : 10 ,
102
+ reason : "test" ,
103
+ } ) ;
104
+ expect ( result . reason ) . to . be . equal ( "test" ) ;
105
+ } ) ;
106
+
116
107
it ( "http get request with url search parameters" , async ( ) => {
117
- const result = await client . httpGetWithURLSearchParams (
118
- { a : 10 , b : { b : 0 } , c : [ 23 , 25 ] , d : { d : 12 } } ,
119
- { pathPrefix : "http://localhost:8081" }
120
- ) ;
108
+ const result = await client . httpGetWithURLSearchParams ( {
109
+ a : 10 ,
110
+ b : { b : 0 } ,
111
+ c : [ 23 , 25 ] ,
112
+ d : { d : 12 } ,
113
+ } ) ;
121
114
expect ( result . urlSearchParamsResult ) . to . equal ( 70 ) ;
122
115
} ) ;
123
116
124
117
it ( "http get request with zero value url search parameters" , async ( ) => {
125
- const result = await client . httpGetWithZeroValueURLSearchParams (
126
- { a : "A" , b : "" , c : { c : 1 , d : [ 1 , 0 , 2 ] , e : false } } ,
127
- { pathPrefix : "http://localhost:8081" }
128
- ) ;
118
+ const result = await client . httpGetWithZeroValueURLSearchParams ( {
119
+ a : "A" ,
120
+ b : "" ,
121
+ c : { c : 1 , d : [ 1 , 0 , 2 ] , e : false } ,
122
+ } ) ;
129
123
expect ( result ) . to . deep . equal ( {
130
124
a : "A" ,
131
125
b : "hello" ,
@@ -134,10 +128,7 @@ describe("test with client class", () => {
134
128
} ) ;
135
129
136
130
it ( "http get request with optional fields" , async ( ) => {
137
- const result = await client . httpGetWithOptionalFields (
138
- { } ,
139
- { pathPrefix : "http://localhost:8081" }
140
- ) ;
131
+ const result = await client . httpGetWithOptionalFields ( { } ) ;
141
132
142
133
expect ( result ) . to . deep . equal ( {
143
134
// all empty fields will be excluded.
0 commit comments