Skip to content

Commit

Permalink
fix: improve coverage on index
Browse files Browse the repository at this point in the history
  • Loading branch information
BelfordZ committed Jul 26, 2019
1 parent 7e59301 commit 8bcf352
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import Client from ".";
import RequestManager from "./RequestManager";
import EventEmitterTransport from "./transports/EventEmitterTransport";

jest.mock("./RequestManager");

const mockedRequestManager = RequestManager as jest.Mock<RequestManager>;
describe("client-js", () => {
it("can be constructed", () => {
const c = new Client(new RequestManager([new EventEmitterTransport("foo://unique")]));
Expand All @@ -14,4 +17,20 @@ describe("client-js", () => {
expect(typeof c.request("my_method", null).then).toEqual("function");
});

describe("startBatch", () => {
it("calls the requestManager.startBatch", () => {
const rm = new mockedRequestManager([new EventEmitterTransport("foo://unique")]);
const c = new Client(rm);
c.startBatch();
expect(mockedRequestManager.mock.instances[0].startBatch).toHaveBeenCalled();
});
});

describe("stopBatch", () => {
const rm = new RequestManager([new EventEmitterTransport("foo://unique")]);
const c = new Client(rm);
c.startBatch();
c.stopBatch();
expect(mockedRequestManager.mock.instances[0].startBatch).toHaveBeenCalled();
});
});

0 comments on commit 8bcf352

Please sign in to comment.