Skip to content

Commit 54dc88d

Browse files
committed
fix test template mistake
1 parent 82f4219 commit 54dc88d

File tree

2 files changed

+37
-29
lines changed

2 files changed

+37
-29
lines changed

templates/cjs/typescript_gapic/test/gapic_$service_$version.ts.njk

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -387,28 +387,6 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
387387
{{- util.verifyUUID(method) }}
388388
});
389389

390-
it('invokes {{ method.name.toCamelCase() }} without error and gaxServerStreamingRetries enabled', async () => {
391-
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({gaxServerStreamingRetries: true});
392-
{%- if method.options and method.options.deprecated %}
393-
const stub = sinon.stub(client, 'warn');
394-
{%- endif %}
395-
client.{{ id.get("initialize") }}();
396-
{{ util.initRequestWithHeaderParam(method) -}}
397-
{{ util.initResponse(method) }}
398-
client.innerApiCalls.{{ method.name.toCamelCase(true) }} = stubSimpleCall(expectedResponse);
399-
const [response] = await client.{{ method.name.toCamelCase() }}(request);
400-
{%- if method.options and method.options.deprecated %}
401-
assert(stub.calledOnce);
402-
{%- endif %}
403-
{%- if method.isDiregapicLRO %}
404-
assert.deepStrictEqual(response.latestResponse, expectedResponse);
405-
{%- else %}
406-
assert.deepStrictEqual(response, expectedResponse);
407-
{%- endif %}
408-
{{- util.verifyHeaderRequestParams(method) }}
409-
{{- util.verifyUUID(method) }}
410-
});
411-
412390
it('invokes {{ method.name.toCamelCase() }} without error using callback', async () => {
413391
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client(
414392
{{- util.initClientOptions(api.rest) -}}
@@ -636,6 +614,32 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
636614
{{- util.verifyHeaderRequestParams(method) }}
637615
});
638616

617+
it('invokes {{ method.name.toCamelCase() }} without error and gaxServerStreamingRetries enabled', async () => {
618+
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({gaxServerStreamingRetries: true});
619+
{%- if method.options and method.options.deprecated %}
620+
const stub = sinon.stub(client, 'warn');
621+
{%- endif %}
622+
client.{{ id.get("initialize") }}();
623+
{{ util.initRequestWithHeaderParam(method) -}}
624+
{{ util.initResponse(method) }}
625+
client.innerApiCalls.{{ method.name.toCamelCase(true) }} = stubServerStreamingCall(expectedResponse);
626+
const stream = client.{{ method.name.toCamelCase() }}(request);
627+
const promise = new Promise((resolve, reject) => {
628+
stream.on('data', (response: protos{{ method.outputInterface }}) => {
629+
resolve(response);
630+
});
631+
stream.on('error', (err: Error) => {
632+
reject(err);
633+
});
634+
});
635+
const response = await promise;
636+
{%- if method.options and method.options.deprecated %}
637+
assert(stub.calledOnce);
638+
{%- endif %}
639+
assert.deepStrictEqual(response, expectedResponse);
640+
{{- util.verifyHeaderRequestParams(method) }}
641+
});
642+
639643
it('invokes {{ method.name.toCamelCase() }} with error', async () => {
640644
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({{- util.initClientOptions(api.rest) -}});
641645
{%- if method.options and method.options.deprecated %}

templates/esm/typescript_gapic/esm/test/gapic_$service_$version.ts.njk

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -630,18 +630,22 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
630630
client.{{ id.get("initialize") }}();
631631
{{ util.initRequestWithHeaderParam(method) -}}
632632
{{ util.initResponse(method) }}
633-
client.innerApiCalls.{{ method.name.toCamelCase(true) }} = stubSimpleCall(expectedResponse);
634-
const [response] = await client.{{ method.name.toCamelCase() }}(request);
633+
client.innerApiCalls.{{ method.name.toCamelCase(true) }} = stubServerStreamingCall(expectedResponse);
634+
const stream = client.{{ method.name.toCamelCase() }}(request);
635+
const promise = new Promise((resolve, reject) => {
636+
stream.on('data', (response: protos{{ method.outputInterface }}) => {
637+
resolve(response);
638+
});
639+
stream.on('error', (err: Error) => {
640+
reject(err);
641+
});
642+
});
643+
const response = await promise;
635644
{%- if method.options and method.options.deprecated %}
636645
assert(stub.calledOnce);
637646
{%- endif %}
638-
{%- if method.isDiregapicLRO %}
639-
assert.deepStrictEqual(response.latestResponse, expectedResponse);
640-
{%- else %}
641647
assert.deepStrictEqual(response, expectedResponse);
642-
{%- endif %}
643648
{{- util.verifyHeaderRequestParams(method) }}
644-
{{- util.verifyUUID(method) }}
645649
});
646650

647651
it('invokes {{ method.name.toCamelCase() }} with error', async () => {

0 commit comments

Comments
 (0)