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
2019-11-22 12:07:14 +01:00

24 lines
683 B
TypeScript

import WebServiceConnector from '../../src/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()) : ''
}
})
})
}
}