diff --git a/packages/google-cloud-translate/protos/protos.d.ts b/packages/google-cloud-translate/protos/protos.d.ts index 828d613de73..81abb38d1cd 100644 --- a/packages/google-cloud-translate/protos/protos.d.ts +++ b/packages/google-cloud-translate/protos/protos.d.ts @@ -685,7 +685,7 @@ export namespace google { public model: string; /** DetectLanguageRequest content. */ - public content: string; + public content?: (string|null); /** DetectLanguageRequest mimeType. */ public mimeType: string; @@ -3926,7 +3926,7 @@ export namespace google { public model: string; /** DetectLanguageRequest content. */ - public content: string; + public content?: (string|null); /** DetectLanguageRequest mimeType. */ public mimeType: string; @@ -4889,7 +4889,7 @@ export namespace google { constructor(properties?: google.cloud.translation.v3beta1.IDocumentInputConfig); /** DocumentInputConfig content. */ - public content: (Uint8Array|string); + public content?: (Uint8Array|string|null); /** DocumentInputConfig gcsSource. */ public gcsSource?: (google.cloud.translation.v3beta1.IGcsSource|null); @@ -7770,19 +7770,19 @@ export namespace google { public selector: string; /** HttpRule get. */ - public get: string; + public get?: (string|null); /** HttpRule put. */ - public put: string; + public put?: (string|null); /** HttpRule post. */ - public post: string; + public post?: (string|null); /** HttpRule delete. */ - public delete: string; + public delete?: (string|null); /** HttpRule patch. */ - public patch: string; + public patch?: (string|null); /** HttpRule custom. */ public custom?: (google.api.ICustomHttpPattern|null); diff --git a/packages/google-cloud-translate/protos/protos.js b/packages/google-cloud-translate/protos/protos.js index 5e4756b138b..e26dff40a5a 100644 --- a/packages/google-cloud-translate/protos/protos.js +++ b/packages/google-cloud-translate/protos/protos.js @@ -1533,11 +1533,11 @@ /** * DetectLanguageRequest content. - * @member {string} content + * @member {string|null|undefined} content * @memberof google.cloud.translation.v3.DetectLanguageRequest * @instance */ - DetectLanguageRequest.prototype.content = ""; + DetectLanguageRequest.prototype.content = null; /** * DetectLanguageRequest mimeType. @@ -9393,11 +9393,11 @@ /** * DetectLanguageRequest content. - * @member {string} content + * @member {string|null|undefined} content * @memberof google.cloud.translation.v3beta1.DetectLanguageRequest * @instance */ - DetectLanguageRequest.prototype.content = ""; + DetectLanguageRequest.prototype.content = null; /** * DetectLanguageRequest mimeType. @@ -11636,11 +11636,11 @@ /** * DocumentInputConfig content. - * @member {Uint8Array} content + * @member {Uint8Array|null|undefined} content * @memberof google.cloud.translation.v3beta1.DocumentInputConfig * @instance */ - DocumentInputConfig.prototype.content = $util.newBuffer([]); + DocumentInputConfig.prototype.content = null; /** * DocumentInputConfig gcsSource. @@ -19344,43 +19344,43 @@ /** * HttpRule get. - * @member {string} get + * @member {string|null|undefined} get * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.get = ""; + HttpRule.prototype.get = null; /** * HttpRule put. - * @member {string} put + * @member {string|null|undefined} put * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.put = ""; + HttpRule.prototype.put = null; /** * HttpRule post. - * @member {string} post + * @member {string|null|undefined} post * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.post = ""; + HttpRule.prototype.post = null; /** * HttpRule delete. - * @member {string} delete + * @member {string|null|undefined} delete * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype["delete"] = ""; + HttpRule.prototype["delete"] = null; /** * HttpRule patch. - * @member {string} patch + * @member {string|null|undefined} patch * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.patch = ""; + HttpRule.prototype.patch = null; /** * HttpRule custom. diff --git a/packages/google-cloud-translate/src/v3/translation_service_client.ts b/packages/google-cloud-translate/src/v3/translation_service_client.ts index 99cd5d9f6d4..f9ece47319a 100644 --- a/packages/google-cloud-translate/src/v3/translation_service_client.ts +++ b/packages/google-cloud-translate/src/v3/translation_service_client.ts @@ -297,13 +297,14 @@ export class TranslationServiceClient { ]; for (const methodName of translationServiceStubMethods) { const callPromise = this.translationServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, + stub => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, (err: Error | null | undefined) => () => { throw err; } @@ -525,11 +526,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.translateText(request, options, callback); } @@ -651,11 +651,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.detectLanguage(request, options, callback); } @@ -780,11 +779,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.getSupportedLanguages(request, options, callback); } @@ -867,11 +865,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getGlossary(request, options, callback); } @@ -1029,11 +1026,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.batchTranslateText(request, options, callback); } @@ -1174,11 +1170,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.createGlossary(request, options, callback); } @@ -1318,11 +1313,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.deleteGlossary(request, options, callback); } @@ -1463,11 +1457,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listGlossaries(request, options, callback); } @@ -1510,11 +1503,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listGlossaries.createStream( @@ -1568,17 +1560,16 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); options = options || {}; const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listGlossaries.asyncIterate( this.innerApiCalls['listGlossaries'] as GaxCall, - (request as unknown) as RequestType, + request as unknown as RequestType, callSettings ) as AsyncIterable; } diff --git a/packages/google-cloud-translate/src/v3beta1/translation_service_client.ts b/packages/google-cloud-translate/src/v3beta1/translation_service_client.ts index 95b96cf5b77..25fac756149 100644 --- a/packages/google-cloud-translate/src/v3beta1/translation_service_client.ts +++ b/packages/google-cloud-translate/src/v3beta1/translation_service_client.ts @@ -315,13 +315,14 @@ export class TranslationServiceClient { ]; for (const methodName of translationServiceStubMethods) { const callPromise = this.translationServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, + stub => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, (err: Error | null | undefined) => () => { throw err; } @@ -544,11 +545,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.translateText(request, options, callback); } @@ -676,11 +676,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.detectLanguage(request, options, callback); } @@ -805,11 +804,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.getSupportedLanguages(request, options, callback); } @@ -961,11 +959,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.translateDocument(request, options, callback); } @@ -1054,11 +1051,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getGlossary(request, options, callback); } @@ -1216,11 +1212,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.batchTranslateText(request, options, callback); } @@ -1407,11 +1402,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.batchTranslateDocument( request, @@ -1556,11 +1550,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.createGlossary(request, options, callback); } @@ -1700,11 +1693,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.deleteGlossary(request, options, callback); } @@ -1858,11 +1850,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listGlossaries(request, options, callback); } @@ -1918,11 +1909,10 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listGlossaries.createStream( @@ -1989,17 +1979,16 @@ export class TranslationServiceClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); options = options || {}; const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listGlossaries.asyncIterate( this.innerApiCalls['listGlossaries'] as GaxCall, - (request as unknown) as RequestType, + request as unknown as RequestType, callSettings ) as AsyncIterable; } diff --git a/packages/google-cloud-translate/test/gapic_translation_service_v3.ts b/packages/google-cloud-translate/test/gapic_translation_service_v3.ts index b18f1caec96..028f63108ba 100644 --- a/packages/google-cloud-translate/test/gapic_translation_service_v3.ts +++ b/packages/google-cloud-translate/test/gapic_translation_service_v3.ts @@ -28,10 +28,9 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message).toObject( - instance as protobuf.Message, - {defaults: true} - ); + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); return (instance.constructor as typeof protobuf.Message).fromObject( filledObject ) as T; @@ -281,9 +280,8 @@ describe('v3.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.translation.v3.TranslateTextResponse() ); - client.innerApiCalls.translateText = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.translateText = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.translateText( request, @@ -393,9 +391,8 @@ describe('v3.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.translation.v3.DetectLanguageResponse() ); - client.innerApiCalls.detectLanguage = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.detectLanguage = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.detectLanguage( request, @@ -474,9 +471,8 @@ describe('v3.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.translation.v3.SupportedLanguages() ); - client.innerApiCalls.getSupportedLanguages = stubSimpleCall( - expectedResponse - ); + client.innerApiCalls.getSupportedLanguages = + stubSimpleCall(expectedResponse); const [response] = await client.getSupportedLanguages(request); assert.deepStrictEqual(response, expectedResponse); assert( @@ -507,9 +503,8 @@ describe('v3.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.translation.v3.SupportedLanguages() ); - client.innerApiCalls.getSupportedLanguages = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.getSupportedLanguages = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.getSupportedLanguages( request, @@ -622,9 +617,8 @@ describe('v3.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.translation.v3.Glossary() ); - client.innerApiCalls.getGlossary = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.getGlossary = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.getGlossary( request, @@ -703,9 +697,8 @@ describe('v3.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.batchTranslateText = stubLongRunningCall( - expectedResponse - ); + client.innerApiCalls.batchTranslateText = + stubLongRunningCall(expectedResponse); const [operation] = await client.batchTranslateText(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); @@ -737,9 +730,8 @@ describe('v3.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.batchTranslateText = stubLongRunningCallWithCallback( - expectedResponse - ); + client.innerApiCalls.batchTranslateText = + stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.batchTranslateText( request, @@ -899,9 +891,8 @@ describe('v3.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.createGlossary = stubLongRunningCall( - expectedResponse - ); + client.innerApiCalls.createGlossary = + stubLongRunningCall(expectedResponse); const [operation] = await client.createGlossary(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); @@ -933,9 +924,8 @@ describe('v3.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.createGlossary = stubLongRunningCallWithCallback( - expectedResponse - ); + client.innerApiCalls.createGlossary = + stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.createGlossary( request, @@ -1095,9 +1085,8 @@ describe('v3.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.deleteGlossary = stubLongRunningCall( - expectedResponse - ); + client.innerApiCalls.deleteGlossary = + stubLongRunningCall(expectedResponse); const [operation] = await client.deleteGlossary(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); @@ -1129,9 +1118,8 @@ describe('v3.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.deleteGlossary = stubLongRunningCallWithCallback( - expectedResponse - ); + client.innerApiCalls.deleteGlossary = + stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.deleteGlossary( request, @@ -1338,9 +1326,8 @@ describe('v3.TranslationServiceClient', () => { new protos.google.cloud.translation.v3.Glossary() ), ]; - client.innerApiCalls.listGlossaries = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.listGlossaries = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.listGlossaries( request, @@ -1418,9 +1405,8 @@ describe('v3.TranslationServiceClient', () => { new protos.google.cloud.translation.v3.Glossary() ), ]; - client.descriptors.page.listGlossaries.createStream = stubPageStreamingCall( - expectedResponse - ); + client.descriptors.page.listGlossaries.createStream = + stubPageStreamingCall(expectedResponse); const stream = client.listGlossariesStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.cloud.translation.v3.Glossary[] = []; @@ -1445,10 +1431,9 @@ describe('v3.TranslationServiceClient', () => { .calledWith(client.innerApiCalls.listGlossaries, request) ); assert.strictEqual( - (client.descriptors.page.listGlossaries - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listGlossaries.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1465,10 +1450,8 @@ describe('v3.TranslationServiceClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listGlossaries.createStream = stubPageStreamingCall( - undefined, - expectedError - ); + client.descriptors.page.listGlossaries.createStream = + stubPageStreamingCall(undefined, expectedError); const stream = client.listGlossariesStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.cloud.translation.v3.Glossary[] = []; @@ -1492,10 +1475,9 @@ describe('v3.TranslationServiceClient', () => { .calledWith(client.innerApiCalls.listGlossaries, request) ); assert.strictEqual( - (client.descriptors.page.listGlossaries - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listGlossaries.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1522,9 +1504,8 @@ describe('v3.TranslationServiceClient', () => { new protos.google.cloud.translation.v3.Glossary() ), ]; - client.descriptors.page.listGlossaries.asyncIterate = stubAsyncIterationCall( - expectedResponse - ); + client.descriptors.page.listGlossaries.asyncIterate = + stubAsyncIterationCall(expectedResponse); const responses: protos.google.cloud.translation.v3.IGlossary[] = []; const iterable = client.listGlossariesAsync(request); for await (const resource of iterable) { @@ -1532,15 +1513,15 @@ describe('v3.TranslationServiceClient', () => { } assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( - (client.descriptors.page.listGlossaries - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listGlossaries.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listGlossaries - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listGlossaries.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1557,10 +1538,8 @@ describe('v3.TranslationServiceClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listGlossaries.asyncIterate = stubAsyncIterationCall( - undefined, - expectedError - ); + client.descriptors.page.listGlossaries.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); const iterable = client.listGlossariesAsync(request); await assert.rejects(async () => { const responses: protos.google.cloud.translation.v3.IGlossary[] = []; @@ -1569,15 +1548,15 @@ describe('v3.TranslationServiceClient', () => { } }); assert.deepStrictEqual( - (client.descriptors.page.listGlossaries - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listGlossaries.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listGlossaries - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listGlossaries.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); diff --git a/packages/google-cloud-translate/test/gapic_translation_service_v3beta1.ts b/packages/google-cloud-translate/test/gapic_translation_service_v3beta1.ts index eec8ba4c25f..d5d7e7d5efd 100644 --- a/packages/google-cloud-translate/test/gapic_translation_service_v3beta1.ts +++ b/packages/google-cloud-translate/test/gapic_translation_service_v3beta1.ts @@ -28,10 +28,9 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message).toObject( - instance as protobuf.Message, - {defaults: true} - ); + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); return (instance.constructor as typeof protobuf.Message).fromObject( filledObject ) as T; @@ -165,49 +164,46 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('should create a client with no option', () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient(); + const client = + new translationserviceModule.v3beta1.TranslationServiceClient(); assert(client); }); it('should create a client with gRPC fallback', () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ fallback: true, - } - ); + }); assert(client); }); it('has initialize method and supports deferred initialization', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); assert.strictEqual(client.translationServiceStub, undefined); await client.initialize(); assert(client.translationServiceStub); }); it('has close method', () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.close(); }); it('has getProjectId method', async () => { const fakeProjectId = 'fake-project-id'; - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); const result = await client.getProjectId(); assert.strictEqual(result, fakeProjectId); @@ -216,12 +212,11 @@ describe('v3beta1.TranslationServiceClient', () => { it('has getProjectId method with callback', async () => { const fakeProjectId = 'fake-project-id'; - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.auth.getProjectId = sinon .stub() .callsArgWith(0, null, fakeProjectId); @@ -240,12 +235,11 @@ describe('v3beta1.TranslationServiceClient', () => { describe('translateText', () => { it('invokes translateText without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.TranslateTextRequest() @@ -273,12 +267,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes translateText without error using callback', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.TranslateTextRequest() @@ -295,9 +288,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.translation.v3beta1.TranslateTextResponse() ); - client.innerApiCalls.translateText = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.translateText = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.translateText( request, @@ -323,12 +315,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes translateText with error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.TranslateTextRequest() @@ -358,12 +349,11 @@ describe('v3beta1.TranslationServiceClient', () => { describe('detectLanguage', () => { it('invokes detectLanguage without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.DetectLanguageRequest() @@ -391,12 +381,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes detectLanguage without error using callback', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.DetectLanguageRequest() @@ -413,9 +402,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.translation.v3beta1.DetectLanguageResponse() ); - client.innerApiCalls.detectLanguage = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.detectLanguage = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.detectLanguage( request, @@ -441,12 +429,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes detectLanguage with error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.DetectLanguageRequest() @@ -476,12 +463,11 @@ describe('v3beta1.TranslationServiceClient', () => { describe('getSupportedLanguages', () => { it('invokes getSupportedLanguages without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.GetSupportedLanguagesRequest() @@ -498,9 +484,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.translation.v3beta1.SupportedLanguages() ); - client.innerApiCalls.getSupportedLanguages = stubSimpleCall( - expectedResponse - ); + client.innerApiCalls.getSupportedLanguages = + stubSimpleCall(expectedResponse); const [response] = await client.getSupportedLanguages(request); assert.deepStrictEqual(response, expectedResponse); assert( @@ -511,12 +496,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes getSupportedLanguages without error using callback', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.GetSupportedLanguagesRequest() @@ -533,9 +517,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.translation.v3beta1.SupportedLanguages() ); - client.innerApiCalls.getSupportedLanguages = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.getSupportedLanguages = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.getSupportedLanguages( request, @@ -561,12 +544,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes getSupportedLanguages with error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.GetSupportedLanguagesRequest() @@ -599,12 +581,11 @@ describe('v3beta1.TranslationServiceClient', () => { describe('translateDocument', () => { it('invokes translateDocument without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.TranslateDocumentRequest() @@ -632,12 +613,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes translateDocument without error using callback', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.TranslateDocumentRequest() @@ -654,9 +634,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.translation.v3beta1.TranslateDocumentResponse() ); - client.innerApiCalls.translateDocument = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.translateDocument = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.translateDocument( request, @@ -682,12 +661,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes translateDocument with error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.TranslateDocumentRequest() @@ -717,12 +695,11 @@ describe('v3beta1.TranslationServiceClient', () => { describe('getGlossary', () => { it('invokes getGlossary without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.GetGlossaryRequest() @@ -750,12 +727,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes getGlossary without error using callback', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.GetGlossaryRequest() @@ -772,9 +748,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.translation.v3beta1.Glossary() ); - client.innerApiCalls.getGlossary = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.getGlossary = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.getGlossary( request, @@ -800,12 +775,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes getGlossary with error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.GetGlossaryRequest() @@ -835,12 +809,11 @@ describe('v3beta1.TranslationServiceClient', () => { describe('batchTranslateText', () => { it('invokes batchTranslateText without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.BatchTranslateTextRequest() @@ -857,9 +830,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.batchTranslateText = stubLongRunningCall( - expectedResponse - ); + client.innerApiCalls.batchTranslateText = + stubLongRunningCall(expectedResponse); const [operation] = await client.batchTranslateText(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); @@ -871,12 +843,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes batchTranslateText without error using callback', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.BatchTranslateTextRequest() @@ -893,9 +864,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.batchTranslateText = stubLongRunningCallWithCallback( - expectedResponse - ); + client.innerApiCalls.batchTranslateText = + stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.batchTranslateText( request, @@ -928,12 +898,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes batchTranslateText with call error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.BatchTranslateTextRequest() @@ -961,12 +930,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes batchTranslateText with LRO error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.BatchTranslateTextRequest() @@ -996,12 +964,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes checkBatchTranslateTextProgress without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const expectedResponse = generateSampleMessage( new operationsProtos.google.longrunning.Operation() @@ -1020,12 +987,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes checkBatchTranslateTextProgress with error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const expectedError = new Error('expected'); @@ -1043,12 +1009,11 @@ describe('v3beta1.TranslationServiceClient', () => { describe('batchTranslateDocument', () => { it('invokes batchTranslateDocument without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.BatchTranslateDocumentRequest() @@ -1065,9 +1030,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.batchTranslateDocument = stubLongRunningCall( - expectedResponse - ); + client.innerApiCalls.batchTranslateDocument = + stubLongRunningCall(expectedResponse); const [operation] = await client.batchTranslateDocument(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); @@ -1079,12 +1043,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes batchTranslateDocument without error using callback', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.BatchTranslateDocumentRequest() @@ -1101,9 +1064,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.batchTranslateDocument = stubLongRunningCallWithCallback( - expectedResponse - ); + client.innerApiCalls.batchTranslateDocument = + stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.batchTranslateDocument( request, @@ -1136,12 +1098,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes batchTranslateDocument with call error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.BatchTranslateDocumentRequest() @@ -1172,12 +1133,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes batchTranslateDocument with LRO error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.BatchTranslateDocumentRequest() @@ -1207,12 +1167,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes checkBatchTranslateDocumentProgress without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const expectedResponse = generateSampleMessage( new operationsProtos.google.longrunning.Operation() @@ -1231,12 +1190,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes checkBatchTranslateDocumentProgress with error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const expectedError = new Error('expected'); @@ -1254,12 +1212,11 @@ describe('v3beta1.TranslationServiceClient', () => { describe('createGlossary', () => { it('invokes createGlossary without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.CreateGlossaryRequest() @@ -1276,9 +1233,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.createGlossary = stubLongRunningCall( - expectedResponse - ); + client.innerApiCalls.createGlossary = + stubLongRunningCall(expectedResponse); const [operation] = await client.createGlossary(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); @@ -1290,12 +1246,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes createGlossary without error using callback', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.CreateGlossaryRequest() @@ -1312,9 +1267,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.createGlossary = stubLongRunningCallWithCallback( - expectedResponse - ); + client.innerApiCalls.createGlossary = + stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.createGlossary( request, @@ -1347,12 +1301,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes createGlossary with call error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.CreateGlossaryRequest() @@ -1380,12 +1333,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes createGlossary with LRO error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.CreateGlossaryRequest() @@ -1415,12 +1367,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes checkCreateGlossaryProgress without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const expectedResponse = generateSampleMessage( new operationsProtos.google.longrunning.Operation() @@ -1439,12 +1390,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes checkCreateGlossaryProgress with error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const expectedError = new Error('expected'); @@ -1462,12 +1412,11 @@ describe('v3beta1.TranslationServiceClient', () => { describe('deleteGlossary', () => { it('invokes deleteGlossary without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.DeleteGlossaryRequest() @@ -1484,9 +1433,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.deleteGlossary = stubLongRunningCall( - expectedResponse - ); + client.innerApiCalls.deleteGlossary = + stubLongRunningCall(expectedResponse); const [operation] = await client.deleteGlossary(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); @@ -1498,12 +1446,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes deleteGlossary without error using callback', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.DeleteGlossaryRequest() @@ -1520,9 +1467,8 @@ describe('v3beta1.TranslationServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.deleteGlossary = stubLongRunningCallWithCallback( - expectedResponse - ); + client.innerApiCalls.deleteGlossary = + stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.deleteGlossary( request, @@ -1555,12 +1501,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes deleteGlossary with call error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.DeleteGlossaryRequest() @@ -1588,12 +1533,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes deleteGlossary with LRO error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.DeleteGlossaryRequest() @@ -1623,12 +1567,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes checkDeleteGlossaryProgress without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const expectedResponse = generateSampleMessage( new operationsProtos.google.longrunning.Operation() @@ -1647,12 +1590,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes checkDeleteGlossaryProgress with error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const expectedError = new Error('expected'); @@ -1670,12 +1612,11 @@ describe('v3beta1.TranslationServiceClient', () => { describe('listGlossaries', () => { it('invokes listGlossaries without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.ListGlossariesRequest() @@ -1711,12 +1652,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes listGlossaries without error using callback', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.ListGlossariesRequest() @@ -1741,9 +1681,8 @@ describe('v3beta1.TranslationServiceClient', () => { new protos.google.cloud.translation.v3beta1.Glossary() ), ]; - client.innerApiCalls.listGlossaries = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.listGlossaries = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.listGlossaries( request, @@ -1769,12 +1708,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes listGlossaries with error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.ListGlossariesRequest() @@ -1802,12 +1740,11 @@ describe('v3beta1.TranslationServiceClient', () => { }); it('invokes listGlossariesStream without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.ListGlossariesRequest() @@ -1825,12 +1762,12 @@ describe('v3beta1.TranslationServiceClient', () => { new protos.google.cloud.translation.v3beta1.Glossary() ), ]; - client.descriptors.page.listGlossaries.createStream = stubPageStreamingCall( - expectedResponse - ); + client.descriptors.page.listGlossaries.createStream = + stubPageStreamingCall(expectedResponse); const stream = client.listGlossariesStream(request); const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.translation.v3beta1.Glossary[] = []; + const responses: protos.google.cloud.translation.v3beta1.Glossary[] = + []; stream.on( 'data', (response: protos.google.cloud.translation.v3beta1.Glossary) => { @@ -1852,21 +1789,19 @@ describe('v3beta1.TranslationServiceClient', () => { .calledWith(client.innerApiCalls.listGlossaries, request) ); assert.strictEqual( - (client.descriptors.page.listGlossaries - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listGlossaries.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); it('invokes listGlossariesStream with error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.ListGlossariesRequest() @@ -1874,13 +1809,12 @@ describe('v3beta1.TranslationServiceClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listGlossaries.createStream = stubPageStreamingCall( - undefined, - expectedError - ); + client.descriptors.page.listGlossaries.createStream = + stubPageStreamingCall(undefined, expectedError); const stream = client.listGlossariesStream(request); const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.translation.v3beta1.Glossary[] = []; + const responses: protos.google.cloud.translation.v3beta1.Glossary[] = + []; stream.on( 'data', (response: protos.google.cloud.translation.v3beta1.Glossary) => { @@ -1901,21 +1835,19 @@ describe('v3beta1.TranslationServiceClient', () => { .calledWith(client.innerApiCalls.listGlossaries, request) ); assert.strictEqual( - (client.descriptors.page.listGlossaries - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listGlossaries.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); it('uses async iteration with listGlossaries without error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.ListGlossariesRequest() @@ -1933,9 +1865,8 @@ describe('v3beta1.TranslationServiceClient', () => { new protos.google.cloud.translation.v3beta1.Glossary() ), ]; - client.descriptors.page.listGlossaries.asyncIterate = stubAsyncIterationCall( - expectedResponse - ); + client.descriptors.page.listGlossaries.asyncIterate = + stubAsyncIterationCall(expectedResponse); const responses: protos.google.cloud.translation.v3beta1.IGlossary[] = []; const iterable = client.listGlossariesAsync(request); for await (const resource of iterable) { @@ -1943,26 +1874,25 @@ describe('v3beta1.TranslationServiceClient', () => { } assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( - (client.descriptors.page.listGlossaries - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listGlossaries.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listGlossaries - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listGlossaries.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); it('uses async iteration with listGlossaries with error', async () => { - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); const request = generateSampleMessage( new protos.google.cloud.translation.v3beta1.ListGlossariesRequest() @@ -1970,27 +1900,26 @@ describe('v3beta1.TranslationServiceClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listGlossaries.asyncIterate = stubAsyncIterationCall( - undefined, - expectedError - ); + client.descriptors.page.listGlossaries.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); const iterable = client.listGlossariesAsync(request); await assert.rejects(async () => { - const responses: protos.google.cloud.translation.v3beta1.IGlossary[] = []; + const responses: protos.google.cloud.translation.v3beta1.IGlossary[] = + []; for await (const resource of iterable) { responses.push(resource!); } }); assert.deepStrictEqual( - (client.descriptors.page.listGlossaries - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listGlossaries.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listGlossaries - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listGlossaries.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -2004,12 +1933,11 @@ describe('v3beta1.TranslationServiceClient', () => { location: 'locationValue', glossary: 'glossaryValue', }; - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); client.pathTemplates.glossaryPathTemplate.render = sinon .stub() @@ -2069,12 +1997,11 @@ describe('v3beta1.TranslationServiceClient', () => { project: 'projectValue', location: 'locationValue', }; - const client = new translationserviceModule.v3beta1.TranslationServiceClient( - { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); + }); client.initialize(); client.pathTemplates.locationPathTemplate.render = sinon .stub()