1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
import React from 'react'
import assert from 'assert'
import { shallow } from 'enzyme'
import sinon from 'sinon'
import CancelTransaction from '../cancel-transaction.component'
import CancelTransactionGasFee from '../cancel-transaction-gas-fee'
import Modal from '../../../modal'
describe('CancelTransaction Component', () => {
const t = key => key
it('should render a CancelTransaction modal', () => {
const wrapper = shallow(
<CancelTransaction
newGasFee="0x1319718a5000"
/>,
{ context: { t }}
)
assert.ok(wrapper)
assert.equal(wrapper.find(Modal).length, 1)
assert.equal(wrapper.find(CancelTransactionGasFee).length, 1)
assert.equal(wrapper.find(CancelTransactionGasFee).props().value, '0x1319718a5000')
assert.equal(wrapper.find('.cancel-transaction__title').text(), 'cancellationGasFee')
assert.equal(wrapper.find('.cancel-transaction__description').text(), 'attemptToCancelDescription')
})
it('should pass the correct props to the Modal component', async () => {
const createCancelTransactionSpy = sinon.stub().callsFake(() => Promise.resolve())
const hideModalSpy = sinon.spy()
const wrapper = shallow(
<CancelTransaction
defaultNewGasPrice="0x3b9aca00"
createCancelTransaction={createCancelTransactionSpy}
hideModal={hideModalSpy}
/>,
{ context: { t }}
)
assert.equal(wrapper.find(Modal).length, 1)
const modalProps = wrapper.find(Modal).props()
assert.equal(modalProps.headerText, 'attemptToCancel')
assert.equal(modalProps.submitText, 'yesLetsTry')
assert.equal(modalProps.cancelText, 'nevermind')
assert.equal(createCancelTransactionSpy.callCount, 0)
assert.equal(hideModalSpy.callCount, 0)
await modalProps.onSubmit()
assert.equal(createCancelTransactionSpy.callCount, 1)
assert.equal(hideModalSpy.callCount, 1)
modalProps.onCancel()
assert.equal(hideModalSpy.callCount, 2)
})
})
|