@@ -145,99 +145,101 @@ function stubAsyncIterationCall<ResponseType>(
145
145
}
146
146
147
147
describe ( 'v1.IDSClient' , ( ) => {
148
- it ( 'has servicePath' , ( ) => {
149
- const servicePath = idsModule . v1 . IDSClient . servicePath ;
150
- assert ( servicePath ) ;
151
- } ) ;
152
-
153
- it ( 'has apiEndpoint' , ( ) => {
154
- const apiEndpoint = idsModule . v1 . IDSClient . apiEndpoint ;
155
- assert ( apiEndpoint ) ;
156
- } ) ;
157
-
158
- it ( 'has port' , ( ) => {
159
- const port = idsModule . v1 . IDSClient . port ;
160
- assert ( port ) ;
161
- assert ( typeof port === 'number' ) ;
162
- } ) ;
163
-
164
- it ( 'should create a client with no option' , ( ) => {
165
- const client = new idsModule . v1 . IDSClient ( ) ;
166
- assert ( client ) ;
167
- } ) ;
148
+ describe ( 'Common methods' , ( ) => {
149
+ it ( 'has servicePath' , ( ) => {
150
+ const servicePath = idsModule . v1 . IDSClient . servicePath ;
151
+ assert ( servicePath ) ;
152
+ } ) ;
168
153
169
- it ( 'should create a client with gRPC fallback ' , ( ) => {
170
- const client = new idsModule . v1 . IDSClient ( {
171
- fallback : true ,
154
+ it ( 'has apiEndpoint ' , ( ) => {
155
+ const apiEndpoint = idsModule . v1 . IDSClient . apiEndpoint ;
156
+ assert ( apiEndpoint ) ;
172
157
} ) ;
173
- assert ( client ) ;
174
- } ) ;
175
158
176
- it ( 'has initialize method and supports deferred initialization' , async ( ) => {
177
- const client = new idsModule . v1 . IDSClient ( {
178
- credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
179
- projectId : 'bogus' ,
159
+ it ( 'has port' , ( ) => {
160
+ const port = idsModule . v1 . IDSClient . port ;
161
+ assert ( port ) ;
162
+ assert ( typeof port === 'number' ) ;
180
163
} ) ;
181
- assert . strictEqual ( client . iDSStub , undefined ) ;
182
- await client . initialize ( ) ;
183
- assert ( client . iDSStub ) ;
184
- } ) ;
185
164
186
- it ( 'has close method for the initialized client' , done => {
187
- const client = new idsModule . v1 . IDSClient ( {
188
- credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
189
- projectId : 'bogus' ,
165
+ it ( 'should create a client with no option' , ( ) => {
166
+ const client = new idsModule . v1 . IDSClient ( ) ;
167
+ assert ( client ) ;
190
168
} ) ;
191
- client . initialize ( ) ;
192
- assert ( client . iDSStub ) ;
193
- client . close ( ) . then ( ( ) => {
194
- done ( ) ;
169
+
170
+ it ( 'should create a client with gRPC fallback' , ( ) => {
171
+ const client = new idsModule . v1 . IDSClient ( {
172
+ fallback : true ,
173
+ } ) ;
174
+ assert ( client ) ;
195
175
} ) ;
196
- } ) ;
197
176
198
- it ( 'has close method for the non-initialized client' , done => {
199
- const client = new idsModule . v1 . IDSClient ( {
200
- credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
201
- projectId : 'bogus' ,
177
+ it ( 'has initialize method and supports deferred initialization' , async ( ) => {
178
+ const client = new idsModule . v1 . IDSClient ( {
179
+ credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
180
+ projectId : 'bogus' ,
181
+ } ) ;
182
+ assert . strictEqual ( client . iDSStub , undefined ) ;
183
+ await client . initialize ( ) ;
184
+ assert ( client . iDSStub ) ;
202
185
} ) ;
203
- assert . strictEqual ( client . iDSStub , undefined ) ;
204
- client . close ( ) . then ( ( ) => {
205
- done ( ) ;
186
+
187
+ it ( 'has close method for the initialized client' , done => {
188
+ const client = new idsModule . v1 . IDSClient ( {
189
+ credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
190
+ projectId : 'bogus' ,
191
+ } ) ;
192
+ client . initialize ( ) ;
193
+ assert ( client . iDSStub ) ;
194
+ client . close ( ) . then ( ( ) => {
195
+ done ( ) ;
196
+ } ) ;
206
197
} ) ;
207
- } ) ;
208
198
209
- it ( 'has getProjectId method' , async ( ) => {
210
- const fakeProjectId = 'fake-project-id' ;
211
- const client = new idsModule . v1 . IDSClient ( {
212
- credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
213
- projectId : 'bogus' ,
199
+ it ( 'has close method for the non-initialized client' , done => {
200
+ const client = new idsModule . v1 . IDSClient ( {
201
+ credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
202
+ projectId : 'bogus' ,
203
+ } ) ;
204
+ assert . strictEqual ( client . iDSStub , undefined ) ;
205
+ client . close ( ) . then ( ( ) => {
206
+ done ( ) ;
207
+ } ) ;
214
208
} ) ;
215
- client . auth . getProjectId = sinon . stub ( ) . resolves ( fakeProjectId ) ;
216
- const result = await client . getProjectId ( ) ;
217
- assert . strictEqual ( result , fakeProjectId ) ;
218
- assert ( ( client . auth . getProjectId as SinonStub ) . calledWithExactly ( ) ) ;
219
- } ) ;
220
209
221
- it ( 'has getProjectId method with callback' , async ( ) => {
222
- const fakeProjectId = 'fake-project-id' ;
223
- const client = new idsModule . v1 . IDSClient ( {
224
- credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
225
- projectId : 'bogus' ,
210
+ it ( 'has getProjectId method' , async ( ) => {
211
+ const fakeProjectId = 'fake-project-id' ;
212
+ const client = new idsModule . v1 . IDSClient ( {
213
+ credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
214
+ projectId : 'bogus' ,
215
+ } ) ;
216
+ client . auth . getProjectId = sinon . stub ( ) . resolves ( fakeProjectId ) ;
217
+ const result = await client . getProjectId ( ) ;
218
+ assert . strictEqual ( result , fakeProjectId ) ;
219
+ assert ( ( client . auth . getProjectId as SinonStub ) . calledWithExactly ( ) ) ;
226
220
} ) ;
227
- client . auth . getProjectId = sinon
228
- . stub ( )
229
- . callsArgWith ( 0 , null , fakeProjectId ) ;
230
- const promise = new Promise ( ( resolve , reject ) => {
231
- client . getProjectId ( ( err ?: Error | null , projectId ?: string | null ) => {
232
- if ( err ) {
233
- reject ( err ) ;
234
- } else {
235
- resolve ( projectId ) ;
236
- }
221
+
222
+ it ( 'has getProjectId method with callback' , async ( ) => {
223
+ const fakeProjectId = 'fake-project-id' ;
224
+ const client = new idsModule . v1 . IDSClient ( {
225
+ credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
226
+ projectId : 'bogus' ,
227
+ } ) ;
228
+ client . auth . getProjectId = sinon
229
+ . stub ( )
230
+ . callsArgWith ( 0 , null , fakeProjectId ) ;
231
+ const promise = new Promise ( ( resolve , reject ) => {
232
+ client . getProjectId ( ( err ?: Error | null , projectId ?: string | null ) => {
233
+ if ( err ) {
234
+ reject ( err ) ;
235
+ } else {
236
+ resolve ( projectId ) ;
237
+ }
238
+ } ) ;
237
239
} ) ;
240
+ const result = await promise ;
241
+ assert . strictEqual ( result , fakeProjectId ) ;
238
242
} ) ;
239
- const result = await promise ;
240
- assert . strictEqual ( result , fakeProjectId ) ;
241
243
} ) ;
242
244
243
245
describe ( 'getEndpoint' , ( ) => {
0 commit comments