2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import { mount } from 'enzyme';
|
2021-03-16 22:00:08 +01:00
|
|
|
import RejectTransactionsModal from './reject-transactions.container';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('Reject Transactions Model', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
let wrapper;
|
2020-01-30 20:34:45 +01:00
|
|
|
|
|
|
|
const props = {
|
|
|
|
onSubmit: sinon.spy(),
|
|
|
|
hideModal: sinon.spy(),
|
|
|
|
unapprovedTxCount: 2,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
beforeEach(() => {
|
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
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
afterEach(() => {
|
2021-02-04 19:15:23 +01:00
|
|
|
props.hideModal.resetHistory();
|
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('hides modal when cancel button is clicked', () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const cancelButton = wrapper.find(
|
|
|
|
'.btn-default.modal-container__footer-button',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
cancelButton.simulate('click');
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.hideModal.calledOnce).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('onSubmit is called and hides modal when reject all clicked', async () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const rejectAllButton = wrapper.find(
|
|
|
|
'.btn-secondary.modal-container__footer-button',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
rejectAllButton.simulate('click');
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(await props.onSubmit.calledOnce).toStrictEqual(true);
|
|
|
|
expect(props.hideModal.calledOnce).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|