Skip to content

Commit

Permalink
feat: use explicit mocha imports (#187)
Browse files Browse the repository at this point in the history
* feat: use explicit mocha imports

* fixy
  • Loading branch information
JustinBeckwith authored and alexander-fenster committed Dec 29, 2019
1 parent 034d991 commit 5d8608f
Show file tree
Hide file tree
Showing 34 changed files with 151 additions and 169 deletions.
21 changes: 0 additions & 21 deletions templates/typescript_gapic/system-test/.eslintrc.yml.njk

This file was deleted.

1 change: 1 addition & 0 deletions templates/typescript_gapic/system-test/install.ts.njk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
{{license.license()}}
import { packNTest } from 'pack-n-play';
import { readFileSync } from 'fs';
import { describe, it } from 'mocha';

describe('typescript consumer tests', () => {

Expand Down
33 changes: 17 additions & 16 deletions templates/typescript_gapic/test/gapic-$service-$version.ts.njk
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.
{{license.license()}}
import * as protosTypes from '../protos/protos';
import * as assert from 'assert';
import { describe, it } from 'mocha';
const {{ service.name.toLowerCase() }}Module = require('../src');
{% if (service.streaming.length > 0) %}
import {PassThrough} from 'stream';
Expand Down Expand Up @@ -56,7 +57,7 @@ function mockSimpleGrpcMethod(expectedRequest: {}, response: {} | null, error: F
callback(null, response);
} else {
callback(null);
}
}
};
}
{%- endif %}
Expand Down Expand Up @@ -135,7 +136,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
it('should create a client with no option', () => {
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client();
assert(client);
});
});
it('should create a client with gRPC fallback', () => {
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({
fallback: true,
Expand All @@ -147,7 +148,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
it('invokes {{ method.name.toCamelCase() }} without error', done => {
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
projectId: 'bogus',
});
// Mock request
{{ util.initRequestWithHeaderParam(method) }}
Expand All @@ -169,7 +170,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
it('invokes {{ method.name.toCamelCase() }} with error', done => {
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
projectId: 'bogus',
});
// Mock request
{{ util.initRequestWithHeaderParam(method) }}
Expand All @@ -195,7 +196,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
it('invokes {{ method.name.toCamelCase() }} without error', done => {
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
projectId: 'bogus',
});
// Mock request
{{ util.initRequestWithHeaderParam(method) }}
Expand All @@ -220,7 +221,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
it('invokes {{ method.name.toCamelCase() }} with error', done => {
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
projectId: 'bogus',
});
// Mock request
{{ util.initRequestWithHeaderParam(method) }}
Expand Down Expand Up @@ -250,7 +251,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
it('invokes {{ method.name.toCamelCase() }} without error', done => {
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
projectId: 'bogus',
});
// Mock request
const request = {};
Expand All @@ -268,10 +269,10 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
});
stream.write();
});
it('invokes {{ method.name.toCamelCase() }} with error', done => {
it('invokes {{ method.name.toCamelCase() }} with error', done => {
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
projectId: 'bogus',
});
// Mock request
const request = {};
Expand All @@ -288,7 +289,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
assert.strictEqual(err.code, FAKE_STATUS_CODE);
done();
});
stream.write();
stream.write();
});
});
{%- endfor %}
Expand All @@ -297,7 +298,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
it('invokes {{ method.name.toCamelCase() }} without error', done => {
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
projectId: 'bogus',
});
// Mock request
const request = {};
Expand All @@ -313,10 +314,10 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
});
stream.write(request);
});
it('invokes {{ method.name.toCamelCase() }} with error', done => {
it('invokes {{ method.name.toCamelCase() }} with error', done => {
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
projectId: 'bogus',
});
// Mock request
const request = {};
Expand All @@ -328,7 +329,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
assert.fail();
}).on('error', (err: FakeError) => {
assert(err instanceof FakeError);
assert.strictEqual(err.code, FAKE_STATUS_CODE);
assert.strictEqual(err.code, FAKE_STATUS_CODE);
done();
});
stream.write(request);
Expand All @@ -340,7 +341,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
it('invokes {{ method.name.toCamelCase() }} without error', done => {
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
projectId: 'bogus',
});
// Mock request
{{ util.initRequestWithHeaderParam(method) }}
Expand All @@ -362,7 +363,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => {
it('invokes {{ method.name.toCamelCase() }}Stream without error', done => {
const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
projectId: 'bogus',
});
// Mock request
{{ util.initRequestWithHeaderParam(method) }}
Expand Down
1 change: 1 addition & 0 deletions typescript/test/test_application/test_js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as util from 'util';
import * as child_process from 'child_process';
import * as fs from 'fs-extra';
import * as path from 'path';
import { describe, it } from 'mocha';
const exec = util.promisify(child_process.exec);
const SHOWCASE_LIB = path.join(
__dirname,
Expand Down
1 change: 1 addition & 0 deletions typescript/test/test_application/test_ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as util from 'util';
import * as child_process from 'child_process';
import * as fs from 'fs-extra';
import * as path from 'path';
import { describe, it } from 'mocha';
const exec = util.promisify(child_process.exec);
const SHOWCASE_LIB = path.join(
__dirname,
Expand Down
1 change: 1 addition & 0 deletions typescript/test/test_application_js/browser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

const child_process = require('child_process');
const util = require('util');
const {describe, it} = require('mocha');
const serverProcess = require('./server');
const exec = util.promisify(child_process.exec);

Expand Down
1 change: 1 addition & 0 deletions typescript/test/test_application_js/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const assert = require('assert');
const {describe, it} = require('mocha');
const showcase = require('showcase');

// Fake auth client for fallback
Expand Down
1 change: 1 addition & 0 deletions typescript/test/test_application_js/integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

const util = require('util');
const child_process = require('child_process');
const {describe, it} = require('mocha');
const exec = util.promisify(child_process.exec);
const fs = require('fs-extra');
const path = require('path');
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import { packNTest } from 'pack-n-play';
import { readFileSync } from 'fs';
import { describe, it } from 'mocha';

describe('typescript consumer tests', () => {

Expand Down
Loading

0 comments on commit 5d8608f

Please sign in to comment.