1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-13 21:27:12 +01:00
metamask-extension/ui/components/app/modals/reject-transactions/reject-transactions.test.js
2021-04-28 14:53:59 -05:00

46 lines
1.1 KiB
JavaScript

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(() => {
wrapper = mount(<RejectTransactionsModal.WrappedComponent {...props} />, {
context: {
t: (str) => str,
},
});
});
afterEach(() => {
props.hideModal.resetHistory();
});
it('hides modal when cancel button is clicked', () => {
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 () => {
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);
});
});