Skip to content

Commit

Permalink
fix: onNotification not firing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejonas committed Jul 17, 2020
1 parent a638062 commit 0b62f9c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/RequestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class RequestManager {
}

private handleNotification(data: any) {
this.requestChannel.emit(data);
this.requestChannel.emit("notification", data);
}

}
Expand Down
1 change: 0 additions & 1 deletion src/__mocks__/requestData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import url from "url";

export const generateMockNotificationRequest = (method: string, params: any[]): req.IJSONRPCNotification => {
return {
id: null,
jsonrpc: "2.0",
method,
params,
Expand Down
4 changes: 2 additions & 2 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ describe("client-js", () => {
const emitter = new EventEmitter();
const c = new Client(new RequestManager([new EventEmitterTransport(emitter, "from1", "to1")]));
addMockServerTransport(emitter, "from1", "to1://asdf/rpc-notification");
c.onNotification(done);
emitter.emit("to1", generateMockNotificationRequest("foo", ["bar"]));
c.onNotification(() => done());
emitter.emit("to1", JSON.stringify(generateMockNotificationRequest("foo", ["bar"])));
});

it("can register error and subscription handlers", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/transports/TransportRequestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class TransportRequestManager {
if (data instanceof Array) {
payload = data;
}
return payload.every((datum) => (datum.result !== undefined || datum.error !== undefined));
return payload.every((datum) => (datum.result !== undefined || datum.error !== undefined || datum.method !== undefined));
}

private processResult(payload: any, prom: IRequestPromise) {
Expand Down

0 comments on commit 0b62f9c

Please sign in to comment.