1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
squid-js/test/__mocks__/WebServiceConnector.mock.ts
2020-01-29 14:38:44 +01:00

26 lines
741 B
TypeScript

import { WebServiceConnector } from '../../src/ocean/utils/WebServiceConnector'
// @ts-ignore
export default class WebServiceConnectorMock extends WebServiceConnector {
constructor(private returnData: any) {
super()
}
// @ts-ignore
private async fetch(url, opts): Promise<any> {
return new Promise((resolve, reject) => {
resolve({
ok: true,
json: () => {
return this.returnData ? this.returnData : {}
},
text: () => {
return this.returnData
? JSON.stringify(this.returnData.toString())
: ''
}
})
})
}
}