text: "use strict";
  
  var _mockWs = require("../../test/mockWs");
  
  var _ = require("./");
  
  // Copyright 2017-2020 @polkadot/rpc-provider authors & contributors
  // SPDX-License-Identifier: Apache-2.0
  let ws;
  let mock;
  
  function createMock(requests) {
    mock = (0, _mockWs.mockWs)(requests);
  }
  
  function createWs(autoConnect = 1000) {
    ws = new _.WsProvider(_mockWs.TEST_WS_URL, autoConnect);
    return ws.isReady;
  }
  
  describe('subscribe', () => {
    let globalWs;
    beforeEach(() => {
      globalWs = global.WebSocket;
    });
    afterEach(() => {
      global.WebSocket = globalWs;
  
      if (mock) {
        mock.done();
      }
    });
    it('adds subscriptions', () => {
      createMock([{
        id: 1,
        method: 'test_sub',
        reply: {
          result: 1
        }
      }]);
      return createWs().then(ws => ws.subscribe('type', 'test_sub', [], cb => {
        expect(cb).toEqual(expect.anything());
      }).then(id => {
        expect(id).toEqual(1);
      }));
    });
  });