@@ -113,99 +113,101 @@ function stubAsyncIterationCall<ResponseType>(
113
113
}
114
114
115
115
describe ( 'v1.PublisherClient' , ( ) => {
116
- it ( 'has servicePath' , ( ) => {
117
- const servicePath = publisherModule . v1 . PublisherClient . servicePath ;
118
- assert ( servicePath ) ;
119
- } ) ;
120
-
121
- it ( 'has apiEndpoint' , ( ) => {
122
- const apiEndpoint = publisherModule . v1 . PublisherClient . apiEndpoint ;
123
- assert ( apiEndpoint ) ;
124
- } ) ;
125
-
126
- it ( 'has port' , ( ) => {
127
- const port = publisherModule . v1 . PublisherClient . port ;
128
- assert ( port ) ;
129
- assert ( typeof port === 'number' ) ;
130
- } ) ;
116
+ describe ( 'Common methods' , ( ) => {
117
+ it ( 'has servicePath' , ( ) => {
118
+ const servicePath = publisherModule . v1 . PublisherClient . servicePath ;
119
+ assert ( servicePath ) ;
120
+ } ) ;
131
121
132
- it ( 'should create a client with no option ' , ( ) => {
133
- const client = new publisherModule . v1 . PublisherClient ( ) ;
134
- assert ( client ) ;
135
- } ) ;
122
+ it ( 'has apiEndpoint ' , ( ) => {
123
+ const apiEndpoint = publisherModule . v1 . PublisherClient . apiEndpoint ;
124
+ assert ( apiEndpoint ) ;
125
+ } ) ;
136
126
137
- it ( 'should create a client with gRPC fallback' , ( ) => {
138
- const client = new publisherModule . v1 . PublisherClient ( {
139
- fallback : true ,
127
+ it ( 'has port' , ( ) => {
128
+ const port = publisherModule . v1 . PublisherClient . port ;
129
+ assert ( port ) ;
130
+ assert ( typeof port === 'number' ) ;
140
131
} ) ;
141
- assert ( client ) ;
142
- } ) ;
143
132
144
- it ( 'has initialize method and supports deferred initialization' , async ( ) => {
145
- const client = new publisherModule . v1 . PublisherClient ( {
146
- credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
147
- projectId : 'bogus' ,
133
+ it ( 'should create a client with no option' , ( ) => {
134
+ const client = new publisherModule . v1 . PublisherClient ( ) ;
135
+ assert ( client ) ;
148
136
} ) ;
149
- assert . strictEqual ( client . publisherStub , undefined ) ;
150
- await client . initialize ( ) ;
151
- assert ( client . publisherStub ) ;
152
- } ) ;
153
137
154
- it ( 'has close method for the initialized client' , done => {
155
- const client = new publisherModule . v1 . PublisherClient ( {
156
- credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
157
- projectId : 'bogus' ,
138
+ it ( 'should create a client with gRPC fallback' , ( ) => {
139
+ const client = new publisherModule . v1 . PublisherClient ( {
140
+ fallback : true ,
141
+ } ) ;
142
+ assert ( client ) ;
158
143
} ) ;
159
- client . initialize ( ) ;
160
- assert ( client . publisherStub ) ;
161
- client . close ( ) . then ( ( ) => {
162
- done ( ) ;
144
+
145
+ it ( 'has initialize method and supports deferred initialization' , async ( ) => {
146
+ const client = new publisherModule . v1 . PublisherClient ( {
147
+ credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
148
+ projectId : 'bogus' ,
149
+ } ) ;
150
+ assert . strictEqual ( client . publisherStub , undefined ) ;
151
+ await client . initialize ( ) ;
152
+ assert ( client . publisherStub ) ;
163
153
} ) ;
164
- } ) ;
165
154
166
- it ( 'has close method for the non-initialized client' , done => {
167
- const client = new publisherModule . v1 . PublisherClient ( {
168
- credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
169
- projectId : 'bogus' ,
155
+ it ( 'has close method for the initialized client' , done => {
156
+ const client = new publisherModule . v1 . PublisherClient ( {
157
+ credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
158
+ projectId : 'bogus' ,
159
+ } ) ;
160
+ client . initialize ( ) ;
161
+ assert ( client . publisherStub ) ;
162
+ client . close ( ) . then ( ( ) => {
163
+ done ( ) ;
164
+ } ) ;
170
165
} ) ;
171
- assert . strictEqual ( client . publisherStub , undefined ) ;
172
- client . close ( ) . then ( ( ) => {
173
- done ( ) ;
166
+
167
+ it ( 'has close method for the non-initialized client' , done => {
168
+ const client = new publisherModule . v1 . PublisherClient ( {
169
+ credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
170
+ projectId : 'bogus' ,
171
+ } ) ;
172
+ assert . strictEqual ( client . publisherStub , undefined ) ;
173
+ client . close ( ) . then ( ( ) => {
174
+ done ( ) ;
175
+ } ) ;
174
176
} ) ;
175
- } ) ;
176
177
177
- it ( 'has getProjectId method' , async ( ) => {
178
- const fakeProjectId = 'fake-project-id' ;
179
- const client = new publisherModule . v1 . PublisherClient ( {
180
- credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
181
- projectId : 'bogus' ,
178
+ it ( 'has getProjectId method' , async ( ) => {
179
+ const fakeProjectId = 'fake-project-id' ;
180
+ const client = new publisherModule . v1 . PublisherClient ( {
181
+ credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
182
+ projectId : 'bogus' ,
183
+ } ) ;
184
+ client . auth . getProjectId = sinon . stub ( ) . resolves ( fakeProjectId ) ;
185
+ const result = await client . getProjectId ( ) ;
186
+ assert . strictEqual ( result , fakeProjectId ) ;
187
+ assert ( ( client . auth . getProjectId as SinonStub ) . calledWithExactly ( ) ) ;
182
188
} ) ;
183
- client . auth . getProjectId = sinon . stub ( ) . resolves ( fakeProjectId ) ;
184
- const result = await client . getProjectId ( ) ;
185
- assert . strictEqual ( result , fakeProjectId ) ;
186
- assert ( ( client . auth . getProjectId as SinonStub ) . calledWithExactly ( ) ) ;
187
- } ) ;
188
189
189
- it ( 'has getProjectId method with callback' , async ( ) => {
190
- const fakeProjectId = 'fake-project-id' ;
191
- const client = new publisherModule . v1 . PublisherClient ( {
192
- credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
193
- projectId : 'bogus' ,
194
- } ) ;
195
- client . auth . getProjectId = sinon
196
- . stub ( )
197
- . callsArgWith ( 0 , null , fakeProjectId ) ;
198
- const promise = new Promise ( ( resolve , reject ) => {
199
- client . getProjectId ( ( err ?: Error | null , projectId ?: string | null ) => {
200
- if ( err ) {
201
- reject ( err ) ;
202
- } else {
203
- resolve ( projectId ) ;
204
- }
190
+ it ( 'has getProjectId method with callback' , async ( ) => {
191
+ const fakeProjectId = 'fake-project-id' ;
192
+ const client = new publisherModule . v1 . PublisherClient ( {
193
+ credentials : { client_email : 'bogus' , private_key : 'bogus' } ,
194
+ projectId : 'bogus' ,
195
+ } ) ;
196
+ client . auth . getProjectId = sinon
197
+ . stub ( )
198
+ . callsArgWith ( 0 , null , fakeProjectId ) ;
199
+ const promise = new Promise ( ( resolve , reject ) => {
200
+ client . getProjectId ( ( err ?: Error | null , projectId ?: string | null ) => {
201
+ if ( err ) {
202
+ reject ( err ) ;
203
+ } else {
204
+ resolve ( projectId ) ;
205
+ }
206
+ } ) ;
205
207
} ) ;
208
+ const result = await promise ;
209
+ assert . strictEqual ( result , fakeProjectId ) ;
206
210
} ) ;
207
- const result = await promise ;
208
- assert . strictEqual ( result , fakeProjectId ) ;
209
211
} ) ;
210
212
211
213
describe ( 'createTopic' , ( ) => {
0 commit comments