From 8f798969952a440722d638bb74440eaa2124ccad Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Mon, 5 Nov 2018 09:03:02 -0800 Subject: [PATCH] refactor: clean up lodash and use strict (#342) --- package.json | 14 ++++++++---- src/api_callable.ts | 7 +----- src/auth.ts | 1 - src/bundling.ts | 6 ++--- src/gax.ts | 2 -- src/grpc.ts | 10 ++++---- src/index.ts | 34 +++++++++++---------------- src/operations_client.ts | 6 ++--- src/paged_iteration.ts | 8 +++---- src/parser_extras.ts | 7 +----- src/path_template.ts | 5 ++-- src/path_template_parser.pegjs | 5 ++-- src/path_template_parser.ts | 8 ++----- src/routing_header.ts | 2 -- src/streaming.ts | 6 ++--- test/api_callable.ts | 8 +++---- test/auth.ts | 1 - test/bundling.ts | 42 +++++++++++++++------------------- test/gax.ts | 3 +-- test/grpc.ts | 11 ++++----- test/longrunning.ts | 10 ++++---- test/paged_iteration.ts | 10 ++++---- test/path_template.ts | 7 +++--- test/path_template_parser.ts | 1 - test/routing_header.ts | 1 - test/streaming.ts | 9 +++----- test/utils.ts | 6 ++--- 27 files changed, 88 insertions(+), 142 deletions(-) diff --git a/package.json b/package.json index 92ba81aec..26b073463 100644 --- a/package.json +++ b/package.json @@ -17,18 +17,21 @@ "google-proto-files": "^0.17.0", "grpc": "^1.15.1", "is-stream-ended": "^0.1.4", - "lodash": "^4.17.10", + "lodash.at": "^4.6.0", + "lodash.flatten": "^4.4.0", + "lodash.has": "^4.5.2", "protobufjs": "^6.8.8", "retry-request": "^4.0.0", - "semver": "^5.5.1", - "through2": "^2.0.3" + "semver": "^5.5.1" }, "devDependencies": { "@types/chai": "^4.1.3", "@types/duplexify": "^3.5.0", "@types/extend": "^3.0.0", "@types/globby": "^8.0.0", - "@types/lodash": "^4.14.109", + "@types/lodash.at": "^4.6.4", + "@types/lodash.flatten": "^4.4.4", + "@types/lodash.has": "^4.5.4", "@types/mocha": "^5.2.1", "@types/node": "^10.3.2", "@types/proxyquire": "^1.3.28", @@ -54,7 +57,8 @@ "sinon": "^7.0.0", "source-map-support": "^0.5.6", "stream-events": "^1.0.4", - "typescript": "~3.1.0" + "through2": "^2.0.3", + "typescript": "~3.1.5" }, "scripts": { "codecov": "istanbul test ./node_modules/mocha/bin/_mocha -- build/test --reporter spec --slow 500 && ./node_modules/codecov/bin/codecov", diff --git a/src/api_callable.ts b/src/api_callable.ts index d1ff61513..32810b18c 100644 --- a/src/api_callable.ts +++ b/src/api_callable.ts @@ -33,13 +33,8 @@ * Provides function wrappers that implement page streaming and retrying. */ -'use strict'; - -import * as util from 'util'; -import {RetryOptions, CallSettings} from './gax'; -import {Duplex} from 'stream'; +import {CallSettings, RetryOptions} from './gax'; import {GoogleError} from './GoogleError'; -import {BundleDescriptor, PageDescriptor} from '.'; export interface ArgumentFunction { (argument: {}, callback: APICallback): void; diff --git a/src/auth.ts b/src/auth.ts index 0909d13c6..0f6afd942 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -30,7 +30,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -'use strict'; import {GoogleError} from './GoogleError'; diff --git a/src/bundling.ts b/src/bundling.ts index 73892b0a5..aeeb80aaf 100644 --- a/src/bundling.ts +++ b/src/bundling.ts @@ -33,9 +33,7 @@ * Provides behavior that supports request bundling. */ -'use strict'; - -import * as _ from 'lodash'; +import at = require('lodash.at'); import {NormalApiCaller, APICall, PromiseCanceller, APICallback} from './api_callable'; import {GoogleError} from './GoogleError'; import {CallSettings} from './gax'; @@ -62,7 +60,7 @@ export function computeBundleId(obj: {}, discriminatorFields: string[]) { const ids: Array<{}|null> = []; let hasIds = false; for (let i = 0; i < discriminatorFields.length; ++i) { - const id = _.at(obj, discriminatorFields[i])[0]; + const id = at(obj, discriminatorFields[i])[0]; if (id === undefined) { ids.push(null); } else { diff --git a/src/gax.ts b/src/gax.ts index 6578d2193..e1ca10fa9 100644 --- a/src/gax.ts +++ b/src/gax.ts @@ -33,8 +33,6 @@ * Google API Extensions */ -'use strict'; - import {BundleOptions} from './bundling'; /** diff --git a/src/grpc.ts b/src/grpc.ts index bbfac73bb..e76deab68 100644 --- a/src/grpc.ts +++ b/src/grpc.ts @@ -29,18 +29,18 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -'use strict'; +import * as grpcProtoLoaderTypes from '@grpc/proto-loader'; // for types only import * as fs from 'fs'; import * as globby from 'globby'; -import * as grpcTypes from 'grpc'; // for types only -import * as grpcProtoLoaderTypes from '@grpc/proto-loader'; // for types only +import {GoogleAuth, GoogleAuthOptions} from 'google-auth-library'; +import * as grpcTypes from 'grpc'; // for types only +import {OutgoingHttpHeaders} from 'http'; import * as path from 'path'; import * as protobuf from 'protobufjs'; import * as semver from 'semver'; -import {GoogleAuth, GoogleAuthOptions} from 'google-auth-library'; + import * as gax from './gax'; -import {OutgoingHttpHeaders} from 'http'; let googleProtoFilesDir = require('google-proto-files')('..'); googleProtoFilesDir = path.normalize(googleProtoFilesDir); diff --git a/src/index.ts b/src/index.ts index ee5bf7abd..b6a5afbc6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,40 +29,32 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -'use strict'; - import * as extend from 'extend'; +import {GrpcClient, GrpcClientOptions} from './grpc'; import * as operationsClient from './operations_client'; import * as routingHeader from './routing_header'; -import {GrpcClient, GrpcClientOptions} from './grpc'; export {GoogleAuth, GoogleAuthOptions} from 'google-auth-library'; -export {routingHeader}; -export {constructSettings, CallOptions, ClientConfig} from './gax'; -export {StreamType, StreamDescriptor} from './streaming'; -export {LongrunningDescriptor, operation} from './longrunning'; -export {BundleDescriptor, BundleExecutor} from './bundling'; -export {PathTemplate} from './path_template'; -export {PageDescriptor} from './paged_iteration'; export {createApiCall} from './api_callable'; +export {BundleDescriptor, BundleExecutor} from './bundling'; +export {CallOptions, ClientConfig, constructSettings} from './gax'; export {GoogleError} from './GoogleError'; -export {ClientStub, ClientStubOptions, GrpcClient, GrpcClientOptions, GrpcModule, GrpcObject, GoogleProtoFilesRoot, Metadata, MetadataValue} from './grpc'; +export {ClientStub, ClientStubOptions, GoogleProtoFilesRoot, GrpcClient, GrpcClientOptions, GrpcModule, GrpcObject, Metadata, MetadataValue} from './grpc'; +export {LongrunningDescriptor, operation} from './longrunning'; +export {PageDescriptor} from './paged_iteration'; +export {PathTemplate} from './path_template'; +export {StreamDescriptor, StreamType} from './streaming'; +export {routingHeader}; function lro(options: GrpcClientOptions) { - options = extend( - { - // tslint:disable-next-line no-any - scopes: (lro as any).ALL_SCOPES, - }, - options); + options = extend({scopes: lro.ALL_SCOPES}, options); const gaxGrpc = new GrpcClient(options); return new operationsClient.OperationsClientBuilder(gaxGrpc); } -// tslint:disable-next-line no-any -(lro as any).SERVICE_ADDRESS = operationsClient.SERVICE_ADDRESS; -// tslint:disable-next-line no-any -(lro as any).ALL_SCOPES = operationsClient.ALL_SCOPES; + +lro.SERVICE_ADDRESS = operationsClient.SERVICE_ADDRESS; +lro.ALL_SCOPES = operationsClient.ALL_SCOPES; export {lro}; export const createByteLengthFunction = GrpcClient.createByteLengthFunction; diff --git a/src/operations_client.ts b/src/operations_client.ts index 85e761197..f52df65d6 100644 --- a/src/operations_client.ts +++ b/src/operations_client.ts @@ -23,15 +23,13 @@ * The only allowed edits are to method and file documentation. A 3-way * merge preserves those additions if the generated source changes. */ -/* TODO: introduce line-wrapping so that it never exceeds the limit. */ -/* jscs: disable maximumLineLength */ -'use strict'; import * as extend from 'extend'; + import * as apiCallable from './api_callable'; import * as gax from './gax'; -import * as pathTemplate from './path_template'; import * as pagedIteration from './paged_iteration'; +import * as pathTemplate from './path_template'; const configData = require('./operations_client_config'); diff --git a/src/paged_iteration.ts b/src/paged_iteration.ts index bd185f8a6..c8390e634 100644 --- a/src/paged_iteration.ts +++ b/src/paged_iteration.ts @@ -28,14 +28,12 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -'use strict'; import * as extend from 'extend'; -import * as through2 from 'through2'; import * as ended from 'is-stream-ended'; -import {Transform} from 'stream'; +import {PassThrough, Transform} from 'stream'; -import {NormalApiCaller, APICall, APICallback} from './api_callable'; +import {APICall, APICallback, NormalApiCaller} from './api_callable'; export class PagedIteration extends NormalApiCaller { pageDescriptor: PageDescriptor; @@ -161,7 +159,7 @@ export class PageDescriptor { * @return {Stream} - a new object Stream. */ createStream(apiCall, request, options): Transform { - const stream = through2.obj(); + const stream = new PassThrough({objectMode: true}); options = extend({}, options, {autoPaginate: false}); const maxResults = 'maxResults' in options ? options.maxResults : -1; let pushCount = 0; diff --git a/src/parser_extras.ts b/src/parser_extras.ts index 9b4bb3b3b..be60b8044 100644 --- a/src/parser_extras.ts +++ b/src/parser_extras.ts @@ -30,10 +30,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -'use strict'; import * as util from 'util'; -import * as _ from 'lodash'; import {Segment} from './path_template'; /* constants used in the pegjs parser */ @@ -73,10 +71,7 @@ function allowOnePathWildcard(segments: Segment[]) { * @return {number} the number of terminal segments in the template */ function countTerminals(segments: Segment[]) { - const terms = _.filter(segments, x => { - return x.kind === TERMINAL; - }); - return terms.length; + return segments.filter(x => x.kind === TERMINAL).length; } /** diff --git a/src/path_template.ts b/src/path_template.ts index fca357f50..14708ab25 100644 --- a/src/path_template.ts +++ b/src/path_template.ts @@ -30,13 +30,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -'use strict'; /* * Path template utility. */ -import * as _ from 'lodash'; +import has = require('lodash.has'); import * as util from 'util'; import * as extras from './parser_extras'; const parser = require('./path_template_parser'); @@ -134,7 +133,7 @@ export class PathTemplate { let inABinding = false; this.segments.forEach(segment => { if (segment.kind === extras.BINDING) { - if (!_.has(bindings, segment.literal)) { + if (!has(bindings, segment.literal)) { const msg = util.format( 'Value for key %s is not provided in %s', segment.literal, bindings); diff --git a/src/path_template_parser.pegjs b/src/path_template_parser.pegjs index 5c1006d1b..56494dc0c 100644 --- a/src/path_template_parser.pegjs +++ b/src/path_template_parser.pegjs @@ -32,8 +32,7 @@ */ { - const _ = require('lodash'); - const util = require('util'); + const flatten = require('lodash.flatten'); const extras = require('./parser_extras'); } @@ -56,7 +55,7 @@ bound_segment variable = '{' l:literal '=' segments:unbound_segments '}' { - return _.flatten([ + return flatten([ { kind: extras.BINDING, literal: l }, segments, { kind: extras.END_BINDING, literal: '' } diff --git a/src/path_template_parser.ts b/src/path_template_parser.ts index 66712d568..3abd97a1b 100644 --- a/src/path_template_parser.ts +++ b/src/path_template_parser.ts @@ -1,7 +1,4 @@ -/* eslint-disable */ module.exports = (() => { - 'use strict'; - /* * Generated by PEG.js 0.9.0. * @@ -54,7 +51,7 @@ module.exports = (() => { const peg$c9 = '}'; const peg$c10 = {type: 'literal', value: '}', description: '"}"'}; const peg$c11 = (l, segments) => { - return _.flatten([ + return flatten([ {kind: extras.BINDING, literal: l}, segments, {kind: extras.END_BINDING, literal: ''}, @@ -620,8 +617,7 @@ module.exports = (() => { return s0; } - const _ = require('lodash'); - const util = require('util'); + const flatten = require('lodash.flatten'); const extras = require('./parser_extras'); peg$result = peg$startRuleFunction(); diff --git a/src/routing_header.ts b/src/routing_header.ts index 64ee7a4b8..e7af663c4 100644 --- a/src/routing_header.ts +++ b/src/routing_header.ts @@ -38,8 +38,6 @@ * Generally, these headers are specified as gRPC metadata. */ -'use strict'; - /** * Constructs the routing header from the given params * diff --git a/src/streaming.ts b/src/streaming.ts index 663b8c2ff..e374700e7 100644 --- a/src/streaming.ts +++ b/src/streaming.ts @@ -28,13 +28,13 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -'use strict'; /* This file describes the gRPC-streaming. */ import * as Duplexify from 'duplexify'; -import {Stream, Duplex, DuplexOptions} from 'stream'; -import {APICallback, APICall} from './api_callable'; +import {Duplex, DuplexOptions, Stream} from 'stream'; + +import {APICall, APICallback} from './api_callable'; const retryRequest = require('retry-request'); diff --git a/test/api_callable.ts b/test/api_callable.ts index 028226c68..cb5d64ead 100644 --- a/test/api_callable.ts +++ b/test/api_callable.ts @@ -28,14 +28,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* jshint expr: true*/ - -'use strict'; - import {expect} from 'chai'; import * as sinon from 'sinon'; -import {GoogleError} from '../src/GoogleError'; + import * as gax from '../src/gax'; +import {GoogleError} from '../src/GoogleError'; + import * as utils from './utils'; const fail = utils.fail; diff --git a/test/auth.ts b/test/auth.ts index a3f091273..eca78e032 100644 --- a/test/auth.ts +++ b/test/auth.ts @@ -30,7 +30,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -'use strict'; import {expect} from 'chai'; import * as sinon from 'sinon'; diff --git a/test/bundling.ts b/test/bundling.ts index 6709baca1..42bb8a25e 100644 --- a/test/bundling.ts +++ b/test/bundling.ts @@ -28,13 +28,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -'use strict'; - -import * as bundling from '../src/bundling'; import {expect} from 'chai'; import * as sinon from 'sinon'; + +import * as bundling from '../src/bundling'; + import {createApiCall} from './utils'; -import * as _ from 'lodash'; function createOuter(value, otherValue?) { if (otherValue === undefined) { @@ -168,12 +167,12 @@ describe('deepCopyForResponse', () => { }); it('deep copies special values', () => { - function Copyable(id) { - this.id = id; + class Copyable { + constructor(public id) {} + copy() { + return new Copyable(this.id); + } } - Copyable.prototype.copy = function() { - return new Copyable(this.id); - }; const input = { copyable: new Copyable(0), arraybuffer: new ArrayBuffer(10), @@ -439,11 +438,8 @@ describe('Task', () => { callback(); }); task.run(); - const cancelIds = _.map(task._data, data => { - return data.callback.id; - }); - cancelIds.forEach(id => { - task.cancel(id!); + task._data.forEach(data => { + task.cancel(data.callback.id!); }); }); @@ -504,7 +500,7 @@ describe('Executor', () => { expect(executor._tasks).to.have.property('["id1"]'); expect(executor._tasks).to.have.property('["id2"]'); - expect(_.size(executor._tasks)).to.eq(2); + expect(Object.keys(executor._tasks).length).to.eq(2); let task = executor._tasks['["id1"]']; expect(task._data.length).to.eq(2); @@ -654,7 +650,7 @@ describe('Executor', () => { executor.schedule(spy, {field1: [2], field2: 'id2'}); expect(spy.callCount).to.eq(2); - expect(_.size(executor._tasks)).to.eq(0); + expect(Object.keys(executor._tasks).length).to.eq(0); }); it('respects bytes count', () => { @@ -680,7 +676,7 @@ describe('Executor', () => { executor.schedule(spy, {field1: [2], field2: 'id2'}); expect(spy.callCount).to.eq(2); - expect(_.size(executor._tasks)).to.eq(0); + expect(Object.keys(executor._tasks).length).to.eq(0); }); it('respects element limit', (done) => { @@ -697,15 +693,15 @@ describe('Executor', () => { executor.schedule(spy, {field1: [1, 2], field2: 'id'}); executor.schedule(spy, {field1: [3, 4], field2: 'id'}); expect(spy.callCount).to.eq(0); - expect(_.size(executor._tasks)).to.eq(1); + expect(Object.keys(executor._tasks).length).to.eq(1); executor.schedule(spy, {field1: [5, 6, 7], field2: 'id'}); expect(spy.callCount).to.eq(1); - expect(_.size(executor._tasks)).to.eq(1); + expect(Object.keys(executor._tasks).length).to.eq(1); executor.schedule(spy, {field1: [8, 9, 10, 11, 12], field2: 'id'}); expect(spy.callCount).to.eq(3); - expect(_.size(executor._tasks)).to.eq(0); + expect(Object.keys(executor._tasks).length).to.eq(0); executor.schedule( spy, {field1: [1, 2, 3, 4, 5, 6, 7], field2: 'id'}, err => { @@ -729,15 +725,15 @@ describe('Executor', () => { executor.schedule(spy, {field1: [1, 2], field2: 'id'}); executor.schedule(spy, {field1: [3, 4], field2: 'id'}); expect(spy.callCount).to.eq(0); - expect(_.size(executor._tasks)).to.eq(1); + expect(Object.keys(executor._tasks).length).to.eq(1); executor.schedule(spy, {field1: [5, 6, 7], field2: 'id'}); expect(spy.callCount).to.eq(1); - expect(_.size(executor._tasks)).to.eq(1); + expect(Object.keys(executor._tasks).length).to.eq(1); executor.schedule(spy, {field1: [8, 9, 0, 1, 2], field2: 'id'}); expect(spy.callCount).to.eq(3); - expect(_.size(executor._tasks)).to.eq(0); + expect(Object.keys(executor._tasks).length).to.eq(0); executor.schedule( spy, {field1: [1, 2, 3, 4, 5, 6, 7], field2: 'id'}, err => { diff --git a/test/gax.ts b/test/gax.ts index 20b31031d..b67c28bca 100644 --- a/test/gax.ts +++ b/test/gax.ts @@ -34,10 +34,9 @@ * allowing that causes another errors of non-camelcase symbols anyways. * Therefore quote-props is disabled explicitly only in this file. */ -'use strict'; +import {expect} from 'chai'; import * as gax from '../src/gax'; -import {expect} from 'chai'; const SERVICE_NAME = 'test.interface.v1.api'; diff --git a/test/grpc.ts b/test/grpc.ts index f69c40efc..c84b3a056 100644 --- a/test/grpc.ts +++ b/test/grpc.ts @@ -28,9 +28,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -'use strict'; - -import {GrpcClient, GoogleProtoFilesRoot} from '../src/grpc'; import {expect} from 'chai'; import * as path from 'path'; import * as protobuf from 'protobufjs'; @@ -38,6 +35,8 @@ import * as proxyquire from 'proxyquire'; import * as semver from 'semver'; import * as sinon from 'sinon'; +import {GoogleProtoFilesRoot, GrpcClient} from '../src/grpc'; + // When this flag is set, tests that have to do with loadProto will be skipped. // They are known to not work with grpc-js, as they use a now-deprecated API. const USE_GRPC_JS = !!process.env.GOOGLE_CLOUD_USE_GRPC_JS && @@ -129,10 +128,8 @@ describe('grpc', () => { }); describe('createStub', () => { - function DummyStub(address, creds, options) { - this.address = address; - this.creds = creds; - this.options = options; + class DummyStub { + constructor(public address, public creds, public options) {} } let grpcClient; const dummyChannelCreds = {channelCreds: 'dummyChannelCreds'}; diff --git a/test/longrunning.ts b/test/longrunning.ts index 585ed15d3..66ed86711 100644 --- a/test/longrunning.ts +++ b/test/longrunning.ts @@ -28,17 +28,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* jshint expr: true*/ - -'use strict'; +import {expect} from 'chai'; +import * as sinon from 'sinon'; import * as gax from '../src/gax'; import * as longrunning from '../src/longrunning'; -import {expect} from 'chai'; -import * as sinon from 'sinon'; -import * as utils from './utils'; import {OperationsClient} from '../src/operations_client'; +import * as utils from './utils'; + // tslint:disable-next-line no-any const FAKE_STATUS_CODE_1 = (utils as any).FAKE_STATUS_CODE_1; diff --git a/test/paged_iteration.ts b/test/paged_iteration.ts index 6d6aab99b..35c013a26 100644 --- a/test/paged_iteration.ts +++ b/test/paged_iteration.ts @@ -28,18 +28,16 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* jshint expr: true*/ - -'use strict'; - -import * as util from './utils'; -import {PageDescriptor} from '../src/paged_iteration'; import {expect} from 'chai'; import * as pumpify from 'pumpify'; import * as sinon from 'sinon'; import * as streamEvents from 'stream-events'; import * as through2 from 'through2'; +import {PageDescriptor} from '../src/paged_iteration'; + +import * as util from './utils'; + describe('paged iteration', () => { const pageSize = 3; const pagesToStream = 5; diff --git a/test/path_template.ts b/test/path_template.ts index e01afa885..ee49fa85e 100644 --- a/test/path_template.ts +++ b/test/path_template.ts @@ -30,9 +30,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -'use strict'; -import * as _ from 'lodash'; import {expect} from 'chai'; import {PathTemplate} from '../src/path_template'; @@ -169,8 +167,9 @@ describe('PathTemplate', () => { '/buckets/helloazAZ09-.~_what': 'buckets/helloazAZ09-.~_what', }; - _.forEach(tests, (want, template) => { - it('should render template ' + template + ' ok', () => { + Object.keys(tests).forEach(template => { + const want = tests[template]; + it(`should render template ${template} ok`, () => { const t = new PathTemplate(template); expect(t.inspect()).to.eql(want); }); diff --git a/test/path_template_parser.ts b/test/path_template_parser.ts index 1229f763e..efe7b33ed 100644 --- a/test/path_template_parser.ts +++ b/test/path_template_parser.ts @@ -30,7 +30,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -'use strict'; import {expect} from 'chai'; diff --git a/test/routing_header.ts b/test/routing_header.ts index 184a18dea..fab6aee62 100644 --- a/test/routing_header.ts +++ b/test/routing_header.ts @@ -27,7 +27,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -'use strict'; import {expect} from 'chai'; import {fromParams} from '../src/routing_header'; diff --git a/test/streaming.ts b/test/streaming.ts index 7c059b333..d81a69357 100644 --- a/test/streaming.ts +++ b/test/streaming.ts @@ -28,16 +28,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* jshint expr: true*/ - -'use strict'; +import {expect} from 'chai'; +import * as sinon from 'sinon'; +import * as through2 from 'through2'; import * as apiCallable from '../src/api_callable'; import * as gax from '../src/gax'; import * as streaming from '../src/streaming'; -import {expect} from 'chai'; -import * as sinon from 'sinon'; -import * as through2 from 'through2'; function createApiCall(func, type) { // can't use "createApiCall" in util.js because argument list is different diff --git a/test/utils.ts b/test/utils.ts index 5072cf038..92e93b20d 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -28,11 +28,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -'use strict'; - -import {GoogleError} from '../src/GoogleError'; -import * as gax from '../src/gax'; import * as apiCallable from '../src/api_callable'; +import * as gax from '../src/gax'; +import {GoogleError} from '../src/GoogleError'; const FAKE_STATUS_CODE_1 = (exports.FAKE_STATUS_CODE_1 = 1);