1 |
|
2 |
|
3 |
|
4 |
|
5 | import { ProviderInterface, ProviderInterface$Emitted, ProviderInterface$EmitCb } from '../types';
|
6 |
|
7 | import mocks from './mocks';
|
8 | import on from './on';
|
9 | import send from './send';
|
10 | import state from './state';
|
11 | import subscribe from './subscribe';
|
12 | import unsubscribe from './unsubscribe';
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | export default function mockProvider (): ProviderInterface {
|
19 | const self = state();
|
20 |
|
21 | mocks(self);
|
22 |
|
23 | return {
|
24 | isConnected: (): boolean =>
|
25 | true,
|
26 | on: (type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void =>
|
27 | on(self, type, sub),
|
28 | send: (method: string, params: Array<any>): Promise<any> =>
|
29 | send(self, method, params),
|
30 | subscribe: (type: string, method: string, ...params: Array<any>): Promise<number> =>
|
31 | subscribe(self, type, method, params),
|
32 | unsubscribe: (type: string, method: string, id: number): Promise<boolean> =>
|
33 | unsubscribe(self, type, method, id)
|
34 | };
|
35 | }
|