1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

test - create ethJsQuery stub

This commit is contained in:
frankiebee 2018-01-14 14:00:59 -08:00
parent f0dd4f1923
commit 409b49b411

View File

@ -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))