1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-05 15:35:46 +01:00
metamask-extension/ui/components/app/modals/reject-transactions/reject-transactions.test.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

import React from 'react';
import sinon from 'sinon';
import { mount } from 'enzyme';
import RejectTransactionsModal from './reject-transactions.container';
describe('Reject Transactions Model', () => {
let wrapper;
const props = {
onSubmit: sinon.spy(),
hideModal: sinon.spy(),
unapprovedTxCount: 2,
};
beforeEach(() => {
2020-11-03 00:41:28 +01:00
wrapper = mount(<RejectTransactionsModal.WrappedComponent {...props} />, {
context: {
t: (str) => str,
},
});
});
afterEach(() => {
props.hideModal.resetHistory();
});
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',
);
cancelButton.simulate('click');
expect(props.hideModal.calledOnce).toStrictEqual(true);
});
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',
);
rejectAllButton.simulate('click');
expect(await props.onSubmit.calledOnce).toStrictEqual(true);
expect(props.hideModal.calledOnce).toStrictEqual(true);
});
});