Skip to content

Commit

Permalink
test: add test for initialized instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mok committed Apr 4, 2022
1 parent 24114c0 commit f0ec684
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/client/socket-helper.test.js
Expand Up @@ -5,7 +5,7 @@
"use strict";

describe("socket", () => {
afterEach(() => {
beforeEach(() => {
jest.resetAllMocks();
jest.resetModules();
});
Expand Down Expand Up @@ -77,4 +77,19 @@ describe("socket", () => {
expect(mockClientInstance.onMessage.mock.calls).toMatchSnapshot();
expect(mockHandler.mock.calls).toMatchSnapshot();
});

it("should export initialized client", () => {
const socket = require("../../client/socket").default;

const nonInitializedInstance = require("../../client/socket").client;
expect(nonInitializedInstance).toBe(null);

socket("my.url", {});

const initializedInstance = require("../../client/socket").client;
expect(initializedInstance).not.toBe(null);
expect(typeof initializedInstance.onClose).toBe("function");
expect(typeof initializedInstance.onMessage).toBe("function");
expect(typeof initializedInstance.onOpen).toBe("function");
});
});

0 comments on commit f0ec684

Please sign in to comment.