UNPKG

656 BJavaScriptView Raw
1// Copyright 2017-2018 @polkadot/api-provider authors & contributors
2// This software may be modified and distributed under the terms
3// of the ISC license. See the LICENSE file for details.
4
5import { mockWs, TEST_WS_URL } from '../../test/mockWs';
6
7import Ws from './index';
8
9let ws;
10let mock;
11
12function createWs (requests, autoConnect) {
13 mock = mockWs(requests);
14 ws = new Ws(TEST_WS_URL, autoConnect);
15
16 return ws;
17}
18
19describe('Ws', () => {
20 afterEach(() => {
21 if (mock) {
22 mock.done();
23 mock = null;
24 }
25 });
26
27 it('returns the connected state', () => {
28 expect(
29 createWs([]).isConnected()
30 ).toEqual(false);
31 });
32});