Classify Http & Ws providers (#120)

* Class-ify HttpProvider

* Class-ify WsProvider (tests still WIP)

* Rework tests

* rx-api usage
This commit is contained in:
Jaco Greeff
2018-08-07 16:59:40 +02:00
committed by GitHub
parent f74fd9e01d
commit fe4c34defe
38 changed files with 342 additions and 531 deletions
+5 -5
View File
@@ -2,11 +2,11 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
jest.mock('@polkadot/api-provider/ws', () => () => ({
isConnected: () => true,
on: () => true,
send: () => true
}));
jest.mock('@polkadot/api-provider/ws', () => class {
isConnected = () => true;
on = () => true;
send = () => true;
});
jest.mock('./interface', () => (api, sectionName) => sectionName);
const createApi = require('./index').default;
+2 -2
View File
@@ -8,13 +8,13 @@ import { RxApiInterface } from './types';
import createApi from '@polkadot/api/index';
import interfaces from '@polkadot/jsonrpc';
import createWs from '@polkadot/api-provider/ws';
import Ws from '@polkadot/api-provider/ws';
import createExposed from './api';
import defaults from './defaults';
import createInterface from './interface';
export default function rxApi (provider: ProviderInterface = createWs(defaults.WS_URL)): RxApiInterface {
export default function rxApi (provider: ProviderInterface = new Ws(defaults.WS_URL)): RxApiInterface {
const api = createApi(provider);
return Object.keys(interfaces).reduce((result, type) => {