Add missing exports from RpcError and add test. (#1166)

This commit is contained in:
Eryu Xia 2021-11-12 19:55:38 +00:00 committed by GitHub
parent 53964f3668
commit 1efe741695
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -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;
}
}

View File

@ -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,