You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
2.1 KiB
61 lines
2.1 KiB
4 years ago
|
import React from 'react';
|
||
|
import { shallow } from 'enzyme';
|
||
|
import sinon from 'sinon';
|
||
4 years ago
|
import Modal from '../../modal';
|
||
|
import CancelTransaction from './cancel-transaction.component';
|
||
|
import CancelTransactionGasFee from './cancel-transaction-gas-fee';
|
||
6 years ago
|
|
||
4 years ago
|
describe('CancelTransaction Component', () => {
|
||
4 years ago
|
const t = (key) => key;
|
||
6 years ago
|
|
||
4 years ago
|
it('should render a CancelTransaction modal', () => {
|
||
4 years ago
|
const wrapper = shallow(<CancelTransaction newGasFee="0x1319718a5000" />, {
|
||
|
context: { t },
|
||
4 years ago
|
});
|
||
6 years ago
|
|
||
4 years ago
|
expect(wrapper.find(Modal)).toHaveLength(1);
|
||
|
expect(wrapper.find(CancelTransactionGasFee)).toHaveLength(1);
|
||
|
expect(wrapper.find(CancelTransactionGasFee).props().value).toStrictEqual(
|
||
4 years ago
|
'0x1319718a5000',
|
||
4 years ago
|
);
|
||
4 years ago
|
expect(wrapper.find('.cancel-transaction__title').text()).toStrictEqual(
|
||
4 years ago
|
'cancellationGasFee',
|
||
4 years ago
|
);
|
||
4 years ago
|
expect(
|
||
4 years ago
|
wrapper.find('.cancel-transaction__description').text(),
|
||
4 years ago
|
).toStrictEqual('attemptToCancelDescription');
|
||
4 years ago
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should pass the correct props to the Modal component', async () => {
|
||
4 years ago
|
const createCancelTransactionSpy = sinon
|
||
|
.stub()
|
||
4 years ago
|
.callsFake(() => Promise.resolve());
|
||
|
const hideModalSpy = sinon.spy();
|
||
6 years ago
|
|
||
|
const wrapper = shallow(
|
||
|
<CancelTransaction
|
||
|
defaultNewGasPrice="0x3b9aca00"
|
||
|
createCancelTransaction={createCancelTransactionSpy}
|
||
|
hideModal={hideModalSpy}
|
||
4 years ago
|
showTransactionConfirmedModal={() => undefined}
|
||
6 years ago
|
/>,
|
||
4 years ago
|
{ context: { t } },
|
||
4 years ago
|
);
|
||
6 years ago
|
|
||
4 years ago
|
expect(wrapper.find(Modal)).toHaveLength(1);
|
||
4 years ago
|
const modalProps = wrapper.find(Modal).props();
|
||
6 years ago
|
|
||
4 years ago
|
expect(modalProps.headerText).toStrictEqual('attemptToCancel');
|
||
|
expect(modalProps.submitText).toStrictEqual('yesLetsTry');
|
||
|
expect(modalProps.cancelText).toStrictEqual('nevermind');
|
||
6 years ago
|
|
||
4 years ago
|
expect(createCancelTransactionSpy.callCount).toStrictEqual(0);
|
||
|
expect(hideModalSpy.callCount).toStrictEqual(0);
|
||
4 years ago
|
await modalProps.onSubmit();
|
||
4 years ago
|
expect(createCancelTransactionSpy.callCount).toStrictEqual(1);
|
||
|
expect(hideModalSpy.callCount).toStrictEqual(1);
|
||
4 years ago
|
modalProps.onCancel();
|
||
4 years ago
|
expect(hideModalSpy.callCount).toStrictEqual(2);
|
||
4 years ago
|
});
|
||
|
});
|