1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Update send.utils.test to with better mocks

This commit is contained in:
Whymarrh Whitby 2018-09-27 11:49:21 -02:30
parent 508a712479
commit 3741927d8d

View File

@ -304,10 +304,13 @@ describe('send utils', () => {
selectedAddress: 'mockAddress', selectedAddress: 'mockAddress',
to: '0xisContract', to: '0xisContract',
estimateGasMethod: sinon.stub().callsFake( estimateGasMethod: sinon.stub().callsFake(
(data, cb) => cb( ({to}, cb) => {
data.to.match(/willFailBecauseOf:/) ? { message: data.to.match(/:(.+)$/)[1] } : null, const err = typeof to === 'string' && to.match(/willFailBecauseOf:/)
{ toString: (n) => `0xabc${n}` } ? new Error(to.match(/:(.+)$/)[1])
) : null
const result = { toString: (n) => `0xabc${n}` }
return cb(err, result)
}
), ),
} }
const baseExpectedCall = { const baseExpectedCall = {
@ -407,7 +410,7 @@ describe('send utils', () => {
to: 'isContract willFailBecauseOf:some other error', to: 'isContract willFailBecauseOf:some other error',
})) }))
} catch (err) { } catch (err) {
assert.deepEqual(err, { message: 'some other error' }) assert.equal(err.message, 'some other error')
} }
}) })
}) })