UNPKG

1.09 kBJavaScriptView 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 { TEST_HTTP_URL } from '../../test/mockHttp';
6
7import Http from './index';
8
9describe('Http', () => {
10 let http;
11
12 beforeEach(() => {
13 http = new Http(TEST_HTTP_URL);
14 });
15
16 it('requires an http:// prefixed endpoint', () => {
17 expect(
18 () => new Http('ws://')
19 ).toThrow(/with 'http/);
20 });
21
22 it('allows https:// endpoints', () => {
23 expect(
24 () => new Http('https://')
25 ).not.toThrow();
26 });
27
28 it('always returns isConnected true', () => {
29 expect(http.isConnected()).toEqual(true);
30 });
31
32 it('does not (yet) support subscribe', () => {
33 return http.subscribe().catch((error) => {
34 expect(error.message).toMatch(/does not have subscriptions/);
35 });
36 });
37
38 it('does not (yet) support unsubscribe', () => {
39 return http.unsubscribe().catch((error) => {
40 expect(error.message).toMatch(/does not have subscriptions/);
41 });
42 });
43});