Skip to content

Commit

Permalink
refactored generateDuplexCall now passes basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iangeckeler committed Aug 6, 2019
1 parent a3e00ee commit b6e4a74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion __tests__/callFactories/generateDuplexCall.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("Unit test for generating Duplex Call", () => {

describe("Duplex should have properties", () => {
test("Duplex Call must have head property", () => {
expect(mockServerReadable.hasOwnProperty("head")).toBe(true);
expect(mockDuplex.hasOwnProperty("head")).toBe(true);
});
});

Expand Down
12 changes: 11 additions & 1 deletion lib/callFactories/generateDuplex.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const grpc = require("grpc");

const basicCallDecorator = require("./callDecorators/basicCallDecorator");
const clientStreamDecorator = require("./callDecorators/clientStreamDecorator");
const serverStreamDecorator = require("./callDecorators/serverStreamDecorator");

const generateMeta = require("../utils/generateMeta");

// function will take in a duplex call constructor, and return a class which extends the class with our own built in methods on top
Expand Down Expand Up @@ -31,4 +35,10 @@ function generateDuplex(ServerDuplexStream) {
return ServerDuplexStreamClone;
}

module.exports = generateDuplex;
module.exports = function(ServerDuplexStream) {
const ServerDuplexStreamClone = Object.create(ServerDuplexStream);
basicCallDecorator(ServerDuplexStreamClone, ServerDuplexStream);
clientStreamDecorator(ServerDuplexStreamClone, ServerDuplexStream);
serverStreamDecorator(ServerDuplexStream, ServerDuplexStream);
return ServerDuplexStreamClone;
};

0 comments on commit b6e4a74

Please sign in to comment.