Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: new typescript, strict types #824

Merged
merged 1 commit into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions test/unit/grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('grpc', () => {
'X-Goog-Api-Client': 'gl-node/6.6.0 gccl/0.7.0 gax/0.11.0 grpc/1.1.0',
};
const builder = grpcClient.metadataBuilder(headers);
const abTesting = null;
const abTesting: {} | null = null;
const moreHeaders = {foo: 'bar'};
const metadata = builder(abTesting!, moreHeaders);
assert.deepStrictEqual(metadata.get('foo'), ['bar']);
Expand All @@ -85,7 +85,7 @@ describe('grpc', () => {
'X-Goog-Api-Client': 'gl-node/6.6.0 gccl/0.7.0 gax/0.11.0 grpc/1.1.0',
};
const builder = grpcClient.metadataBuilder(headers);
const abTesting = null;
const abTesting: {} | null = null;
const moreHeaders = {'x-GOOG-api-CLIENT': 'something else'};
const metadata = builder(abTesting!, moreHeaders);
assert.deepStrictEqual(metadata.get('x-goog-api-client'), [
Expand Down Expand Up @@ -117,7 +117,11 @@ describe('grpc', () => {

describe('createStub', () => {
class DummyStub {
constructor(public address: {}, public creds: {}, public options: {}) {}
constructor(
public address: {},
public creds: {},
public options: {[index: string]: string | number | Function}
) {}
}
let grpcClient: GrpcClient;
const dummyChannelCreds = {channelCreds: 'dummyChannelCreds'};
Expand Down Expand Up @@ -195,11 +199,15 @@ describe('grpc', () => {
assert(stub.options.hasOwnProperty(k));
});
// check values
const dummyStub = (stub as unknown) as DummyStub;
assert.strictEqual(
stub.options['grpc.max_send_message_length'],
dummyStub.options['grpc.max_send_message_length'],
10 * 1024 * 1024
);
assert.strictEqual(stub.options['callInvocationTransformer'](), 42);
assert.strictEqual(
(dummyStub.options['callInvocationTransformer'] as Function)(),
42
);
['servicePath', 'port', 'other_dummy_options'].forEach(k => {
assert.strictEqual(stub.options.hasOwnProperty(k), false);
});
Expand Down Expand Up @@ -241,8 +249,9 @@ describe('grpc', () => {
['servicePath', 'port'].forEach(k => {
assert.strictEqual(stub.options.hasOwnProperty(k), false);
});
const dummyStub = (stub as unknown) as DummyStub;
assert.strictEqual(
stub.options['grpc.max_receive_message_length'],
dummyStub.options['grpc.max_receive_message_length'],
10 * 1024 * 1024
);
});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/pagedIteration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ describe('paged iteration', () => {
.then(response => {
assert.ok(Array.isArray(response));
assert(Array.isArray(response[0]));
assert.strictEqual(response[0].length, pageSize);
assert.strictEqual((response[0] as Array<{}>).length, pageSize);
for (let i = 0; i < pageSize; ++i) {
assert.strictEqual(response[0][i], expected);
assert.strictEqual((response[0] as Array<{}>)[i], expected);
expected++;
}
done();
Expand Down