UNPKG

634 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 Ws from './index';
6
7describe('onError', () => {
8 let ws;
9 let errorSpy;
10
11 beforeEach(() => {
12 ws = new Ws('ws://127.0.0.1:1234', false);
13 errorSpy = jest.spyOn(console, 'error');
14 });
15
16 afterEach(() => {
17 errorSpy.mockRestore();
18 });
19
20 it('logs the error', () => {
21 ws.onSocketError('test error');
22
23 expect(errorSpy).toHaveBeenCalledWith(
24 expect.anything(), expect.anything(), 'test error'
25 );
26 });
27});