diff --git a/javascript/net/grpc/web/grpcwebclientbase_test.js b/javascript/net/grpc/web/grpcwebclientbase_test.js index e962d49e..b58d44d4 100644 --- a/javascript/net/grpc/web/grpcwebclientbase_test.js +++ b/javascript/net/grpc/web/grpcwebclientbase_test.js @@ -75,6 +75,33 @@ testSuite({ assertElementsEquals(DEFAULT_UNARY_HEADER_VALUES, Object.values(headers)); }, + async testRpcFalsyResponse() { + const xhr = new XhrIo(); + const client = new GrpcWebClientBase(/* options= */ {}, xhr); + const methodDescriptor = createMethodDescriptor((bytes) => { + assertElementsEquals(DEFAULT_RPC_RESPONSE_DATA, [].slice.call(bytes)); + return 0; + }); + + const response = await new Promise((resolve, reject) => { + client.rpcCall( + 'url', new MockRequest(), /* metadata= */ {}, methodDescriptor, + (error, response) => { + assertNull(error); + resolve(response); + }); + xhr.simulatePartialResponse( + googCrypt.encodeByteArray(new Uint8Array(DEFAULT_RPC_RESPONSE)), + DEFAULT_RESPONSE_HEADERS); + xhr.simulateReadyStateChange(ReadyState.COMPLETE); + }); + + assertEquals(0, response); + const headers = /** @type {!Object} */ (xhr.getLastRequestHeaders()); + assertElementsEquals(DEFAULT_UNARY_HEADERS, Object.keys(headers)); + assertElementsEquals(DEFAULT_UNARY_HEADER_VALUES, Object.values(headers)); + }, + async testDeadline() { const xhr = new XhrIo(); const client = new GrpcWebClientBase(/* options= */ {}, xhr);