Skip to content

Commit

Permalink
fix: add failing notification test
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejonas committed Jul 17, 2020
1 parent 96ff6b8 commit a638062
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Client from ".";
import RequestManager from "./RequestManager";
import EventEmitterTransport from "./transports/EventEmitterTransport";
import { EventEmitter } from "events";
import { addMockServerTransport } from "./__mocks__/eventEmitter";
import { generateMockNotificationRequest } from "./__mocks__/requestData";

describe("client-js", () => {
it("can be constructed", () => {
Expand All @@ -24,6 +26,14 @@ describe("client-js", () => {
expect(typeof c.notify("my_method", null).then).toEqual("function");
});

it("can recieve notifications", (done) => {
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"]));
});

it("can register error and subscription handlers", () => {
const emitter = new EventEmitter();
const c = new Client(new RequestManager([new EventEmitterTransport(emitter, "from1", "to1")]));
Expand Down

0 comments on commit a638062

Please sign in to comment.