2020-01-30 20:34:45 +01:00
|
|
|
import assert from 'assert'
|
2020-08-18 21:18:25 +02:00
|
|
|
import React from 'react'
|
2020-01-30 20:34:45 +01:00
|
|
|
import sinon from 'sinon'
|
|
|
|
import { mount } from 'enzyme'
|
2020-08-19 18:27:05 +02:00
|
|
|
import RejectTransactionsModal from '..'
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Reject Transactions Model', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
let wrapper
|
|
|
|
|
|
|
|
const props = {
|
|
|
|
onSubmit: sinon.spy(),
|
|
|
|
hideModal: sinon.spy(),
|
|
|
|
unapprovedTxCount: 2,
|
|
|
|
}
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
beforeEach(function () {
|
2020-11-03 00:41:28 +01:00
|
|
|
wrapper = mount(<RejectTransactionsModal.WrappedComponent {...props} />, {
|
|
|
|
context: {
|
|
|
|
t: (str) => str,
|
2020-07-14 17:20:41 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
2020-01-30 20:34:45 +01:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
afterEach(function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
props.hideModal.resetHistory()
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
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',
|
|
|
|
)
|
2020-01-30 20:34:45 +01:00
|
|
|
cancelButton.simulate('click')
|
|
|
|
|
|
|
|
assert(props.hideModal.calledOnce)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
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',
|
|
|
|
)
|
2020-01-30 20:34:45 +01:00
|
|
|
rejectAllButton.simulate('click')
|
|
|
|
|
|
|
|
setImmediate(() => {
|
|
|
|
assert(props.onSubmit.calledOnce)
|
|
|
|
assert(props.hideModal.calledOnce)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|