From 1efe741695e7d330a4a56fe2e223fc027f83705c Mon Sep 17 00:00:00 2001 From: Eryu Xia Date: Fri, 12 Nov 2021 19:55:38 +0000 Subject: [PATCH] Add missing exports from RpcError and add test. (#1166) --- javascript/net/grpc/web/rpcerror.js | 4 ++-- packages/grpc-web/test/export_test.js | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/javascript/net/grpc/web/rpcerror.js b/javascript/net/grpc/web/rpcerror.js index 39a12d3..2436bd3 100644 --- a/javascript/net/grpc/web/rpcerror.js +++ b/javascript/net/grpc/web/rpcerror.js @@ -40,9 +40,9 @@ class RpcError extends Error { */ constructor(code, message, metadata = {}) { super(message); - /** @type {!StatusCode} */ + /** @export {!StatusCode} */ this.code = code; - /** @type {!Metadata} */ + /** @export {!Metadata} */ this.metadata = metadata; } } diff --git a/packages/grpc-web/test/export_test.js b/packages/grpc-web/test/export_test.js index f26a8a4..af9d100 100644 --- a/packages/grpc-web/test/export_test.js +++ b/packages/grpc-web/test/export_test.js @@ -15,7 +15,14 @@ describe('grpc-web export test', function() { assert.equal(typeof grpc.web.GrpcWebClientBase.prototype.serverStreaming, 'function'); }); - it('should have grpc StatusCode exported', function() { + it('should have RpcError properties exported', function() { + const rpcError = new grpc.web.RpcError(/* code= */ 0, 'message'); + assert.equal(typeof rpcError.code, 'number'); + assert.equal(typeof rpcError.message, 'string'); + assert.equal(typeof rpcError.metadata, 'object'); + }); + + it('should have StatusCode exported', function() { assert.deepEqual(grpc.web.StatusCode, { ABORTED: 10, ALREADY_EXISTS: 6,