Files
api/packages/rpc-provider/src/mock/mockHttp.ts
T
Jaco 736fd536f9 Use tsconfig references (#4328)
* Use tsconfig references

* Move types-known (temp until lower-level split)

* Sources

* Adjust

* tesconfig.eslint.json

* Bumps

* AdjustAdjust

* Linting passing... a start...

* Adjust

* Merge derive

* Merge

* api-contract-support

* It builds?

* compare locations
2021-12-14 12:04:50 +02:00

24 lines
666 B
TypeScript

// Copyright 2017-2021 @polkadot/rpc-provider authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* eslint-disable */
import nock from 'nock';
export const TEST_HTTP_URL = 'http://localhost:9944';
export function mockHttp (requests: any[]): any {
nock.cleanAll();
return requests.reduce((scope, request: any): nock.Scope => {
return scope
.post('/')
.reply(request.code || 200, (uri: string, body: { id: string }): any => {
scope.body = scope.body || {};
scope.body[request.method] = body;
return Object.assign({ id: body.id, jsonrpc: '2.0' }, request.reply || {});
});
}, nock(TEST_HTTP_URL));
}