Sitelet https://github.com/open-rpc/client-js/commit/8bcf352
Skip to content

Commit 8bcf352

Browse files
committed
fix: improve coverage on index
1 parent 7e59301 commit 8bcf352

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎src/index.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import Client from ".";
22
import RequestManager from "./RequestManager";
33
import EventEmitterTransport from "./transports/EventEmitterTransport";
44

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

20+
describe("startBatch", () => {
21+
it("calls the requestManager.startBatch", () => {
22+
const rm = new mockedRequestManager([new EventEmitterTransport("foo://unique")]);
23+
const c = new Client(rm);
24+
c.startBatch();
25+
expect(mockedRequestManager.mock.instances[0].startBatch).toHaveBeenCalled();
26+
});
27+
});
28+
29+
describe("stopBatch", () => {
30+
const rm = new RequestManager([new EventEmitterTransport("foo://unique")]);
31+
const c = new Client(rm);
32+
c.startBatch();
33+
c.stopBatch();
34+
expect(mockedRequestManager.mock.instances[0].startBatch).toHaveBeenCalled();
35+
});
1736
});

0 commit comments

Comments
 (0)