2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
2022-10-11 19:54:50 +02:00
|
|
|
import { fireEvent, waitFor } from '@testing-library/react';
|
|
|
|
import { renderWithProvider } from '../../../../../test/lib/render-helpers';
|
|
|
|
import RejectTransactionsModal from '.';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('Reject Transactions Model', () => {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
2022-10-11 19:54:50 +02:00
|
|
|
onSubmit: jest.fn(),
|
|
|
|
hideModal: jest.fn(),
|
2020-01-30 20:34:45 +01:00
|
|
|
unapprovedTxCount: 2,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-10-11 19:54:50 +02:00
|
|
|
it('should match snapshot', () => {
|
|
|
|
const { container } = renderWithProvider(
|
|
|
|
<RejectTransactionsModal.WrappedComponent {...props} />,
|
|
|
|
);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-10-11 19:54:50 +02:00
|
|
|
expect(container).toMatchSnapshot();
|
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('hides modal when cancel button is clicked', () => {
|
2022-10-11 19:54:50 +02:00
|
|
|
const { queryByText } = renderWithProvider(
|
|
|
|
<RejectTransactionsModal.WrappedComponent {...props} />,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-10-11 19:54:50 +02:00
|
|
|
fireEvent.click(queryByText('[cancel]'));
|
|
|
|
|
|
|
|
expect(props.onSubmit).not.toHaveBeenCalled();
|
|
|
|
expect(props.hideModal).toHaveBeenCalled();
|
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 () => {
|
2022-10-11 19:54:50 +02:00
|
|
|
const { queryByText } = renderWithProvider(
|
|
|
|
<RejectTransactionsModal.WrappedComponent {...props} />,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-10-11 19:54:50 +02:00
|
|
|
fireEvent.click(queryByText('[rejectAll]'));
|
|
|
|
|
|
|
|
await waitFor(() => {
|
|
|
|
expect(props.onSubmit).toHaveBeenCalled();
|
|
|
|
expect(props.hideModal).toHaveBeenCalled();
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|