1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 19:10:22 +01:00
metamask-extension/ui/app/components/app/modals/reject-transactions/tests/reject-transactions.test.js

50 lines
1.1 KiB
JavaScript
Raw Normal View History

import assert from 'assert'
import React from 'react'
import sinon from 'sinon'
import { mount } from 'enzyme'
import RejectTransactionsModal from '..'
describe('Reject Transactions Model', function () {
let wrapper
const props = {
onSubmit: sinon.spy(),
hideModal: sinon.spy(),
unapprovedTxCount: 2,
}
beforeEach(function () {
2020-11-03 00:41:28 +01:00
wrapper = mount(<RejectTransactionsModal.WrappedComponent {...props} />, {
context: {
t: (str) => str,
},
2020-11-03 00:41:28 +01:00
})
})
afterEach(function () {
props.hideModal.resetHistory()
})
it('hides modal when cancel button is clicked', function () {
2020-11-03 00:41:28 +01:00
const cancelButton = wrapper.find(
'.btn-default.modal-container__footer-button',
)
cancelButton.simulate('click')
assert(props.hideModal.calledOnce)
})
it('onSubmit is called and hides modal when reject all clicked', function (done) {
2020-11-03 00:41:28 +01:00
const rejectAllButton = wrapper.find(
'.btn-secondary.modal-container__footer-button',
)
rejectAllButton.simulate('click')
setImmediate(() => {
assert(props.onSubmit.calledOnce)
assert(props.hideModal.calledOnce)
done()
})
})
})