mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
4f64e3d6c3
Co-authored-by: Antonio Regadas <antonio.regadas@consensys.net> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com>
68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
import React from 'react';
|
|
import configureStore from 'redux-mock-store';
|
|
import { fireEvent, screen } from '@testing-library/react';
|
|
import thunk from 'redux-thunk';
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
|
import ComplianceDetails from './compliance-details';
|
|
|
|
const initState = {
|
|
metamask: {
|
|
institutionalFeatures: {
|
|
complianceProjectId: '',
|
|
complianceClientId: '',
|
|
reportsInProgress: {},
|
|
historicalReports: {
|
|
'0xAddress': [
|
|
{
|
|
reportId: 'reportId',
|
|
address: '0xAddress',
|
|
risk: 'low',
|
|
creatTime: new Date(),
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
};
|
|
const middlewares = [thunk];
|
|
const mockStore = configureStore(middlewares);
|
|
|
|
describe('ComplianceDetails', () => {
|
|
const props = {
|
|
address: '0xAddress',
|
|
onClose: jest.fn(),
|
|
onGenerate: jest.fn(),
|
|
};
|
|
|
|
const store = mockStore(initState);
|
|
|
|
it('should render correctly', () => {
|
|
const { container } = renderWithProvider(
|
|
<ComplianceDetails
|
|
address={props.address}
|
|
onClose={props.onClose}
|
|
onGenerate={props.onGenerate}
|
|
/>,
|
|
store,
|
|
);
|
|
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
it('runs onGenerate fuction', () => {
|
|
renderWithProvider(
|
|
<ComplianceDetails
|
|
address={props.address}
|
|
onClose={props.onClose}
|
|
onGenerate={props.onGenerate}
|
|
/>,
|
|
store,
|
|
);
|
|
|
|
fireEvent.click(screen.queryByTestId('page-container-footer-next'));
|
|
|
|
expect(props.onGenerate).toHaveBeenCalledTimes(1);
|
|
expect(props.onGenerate).toHaveBeenCalledWith(props.address);
|
|
});
|
|
});
|