mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
test - create ethJsQuery stub
This commit is contained in:
parent
f0dd4f1923
commit
409b49b411
@ -5,7 +5,8 @@ module.exports = {
|
||||
createEngineForTestData,
|
||||
providerFromEngine,
|
||||
scaffoldMiddleware,
|
||||
createStubedProvider
|
||||
createEthJsQueryStub,
|
||||
createStubedProvider,
|
||||
}
|
||||
|
||||
|
||||
@ -18,6 +19,18 @@ function providerFromEngine (engine) {
|
||||
return provider
|
||||
}
|
||||
|
||||
function createEthJsQueryStub (stubProvider) {
|
||||
return new Proxy({}, {
|
||||
get: (obj, method) => {
|
||||
return (...params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
stubProvider.sendAsync({ method: `eth_${method}`, params }, (err, ress) => resolve(ress.result))
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function createStubedProvider (resultStub) {
|
||||
const engine = createEngineForTestData()
|
||||
engine.push(scaffoldMiddleware(resultStub))
|
||||
|
Loading…
Reference in New Issue
Block a user