Skip to content

Commit

Permalink
fix: adding mock fetch to mock session for node < 18
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Jan 26, 2023
1 parent 919346d commit 359f9df
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tmp/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ export function isABISerializableObject(value: any): value is ABISerializableObj
return value.constructor && typeof value.constructor.abiName === 'string'
}

function mockFetch(data) {
return Promise.resolve({
json: () => Promise.resolve(data),
text: () => Promise.resolve(JSON.stringify(data)),
})
}

// TODO: Remove this mock session once a real one exists
const mockSession = new Session({
broadcast: false, // Disable broadcasting by default for tests, enable when required.
Expand All @@ -27,6 +34,7 @@ const mockSession = new Session({
walletPlugin: new WalletPluginPrivateKey({
privateKey: PrivateKey.from('5Jtoxgny5tT7NiNFp1MLogviuPJ9NniWjnU4wKzaX4t7pL4kJ8s'),
}),
fetch: mockFetch,
})

export class Contract {
Expand Down

0 comments on commit 359f9df

Please sign in to comment.