Skip to content

Commit

Permalink
added .on metadata functions to client unary
Browse files Browse the repository at this point in the history
  • Loading branch information
iangeckeler committed Aug 13, 2019
1 parent 45ccc12 commit c224c10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ describe("tests for client unary decorator", () => {
mockOn.mockClear();
mockCallback.mockClear();
});

it("if passed metadata as a string, calls callback on the head", () => {
customCall.on("metadata", mockCallback);
expect(mockCallback.mock.calls.length).toBe(1);
});

it("on should accept a data string and callback", () => {
customCall.on("data", mockCallback);
expect(mockCallback.mock.calls.length).toBe(1);
Expand Down
2 changes: 2 additions & 0 deletions lib/callFactories/callDecorators/clientUnaryDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ module.exports = function clientUnaryDecorator(customCall, originalCall) {
} else {
if (string === "data") {
callback(this.body);
} else if (string === "metadata") {
callback(this.head);
} else {
throw new Error('Only the "data" event is support by unary .on');
}
Expand Down

0 comments on commit c224c10

Please sign in to comment.