1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00

Update tx status tests to assert cb called (#8371)

This commit is contained in:
Whymarrh Whitby 2020-04-20 13:26:50 -02:30 committed by GitHub
parent 164923acd1
commit 18eaae2721
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import { strict as assert } from 'assert'
import sinon from 'sinon'
import TxStateManager from '../../../../../app/scripts/controllers/transactions/tx-state-manager'
import { snapshotFromTxMeta } from '../../../../../app/scripts/controllers/transactions/lib/tx-state-history-helpers'
@ -30,15 +31,18 @@ describe('TransactionStateManager', function () {
assert.equal(result[0].status, 'signed')
})
it('should emit a signed event to signal the exciton of callback', function (done) {
it('should emit a signed event to signal the execution of callback', function () {
const tx = { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }
const noop = function () {
done()
}
const clock = sinon.useFakeTimers()
const noop = sinon.spy()
txStateManager.addTx(tx)
txStateManager.on('1:signed', noop)
txStateManager.setTxStatusSigned(1)
clock.runAll()
clock.restore()
assert.ok(noop.calledOnce)
})
})
@ -52,14 +56,18 @@ describe('TransactionStateManager', function () {
assert.equal(result.length, 0)
})
it('should emit a rejected event to signal the exciton of callback', function (done) {
it('should emit a rejected event to signal the execution of callback', function () {
const tx = { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }
const clock = sinon.useFakeTimers()
const noop = sinon.spy()
txStateManager.addTx(tx)
const noop = () => {
done()
}
txStateManager.on('1:rejected', noop)
txStateManager.setTxStatusRejected(1)
clock.runAll()
clock.restore()
assert.ok(noop.calledOnce)
})
})