diff --git a/test/client/socket-helper.test.js b/test/client/socket-helper.test.js index 4951949d6c..17077de0a8 100644 --- a/test/client/socket-helper.test.js +++ b/test/client/socket-helper.test.js @@ -5,7 +5,7 @@ "use strict"; describe("socket", () => { - afterEach(() => { + beforeEach(() => { jest.resetAllMocks(); jest.resetModules(); }); @@ -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"); + }); });