1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 04:46:10 +01:00
metamask-extension/ui/components/app/modals/metametrics-opt-in-modal/metametrics-opt-in-modal.test.js

47 lines
1.4 KiB
JavaScript

import React from 'react';
import { fireEvent, waitFor } from '@testing-library/react';
import { renderWithProvider } from '../../../../../test/lib/render-helpers';
import MetaMetricsOptIn from '.';
describe('MetaMetrics Opt In', () => {
const props = {
setParticipateInMetaMetrics: jest.fn().mockResolvedValue(),
hideModal: jest.fn(),
participateInMetaMetrics: null,
};
it('should match snapshot', () => {
const { container } = renderWithProvider(
<MetaMetricsOptIn.WrappedComponent />,
);
expect(container).toMatchSnapshot();
});
it('passes false to setParticipateInMetaMetrics and hides modal', async () => {
const { queryByText } = renderWithProvider(
<MetaMetricsOptIn.WrappedComponent {...props} />,
);
fireEvent.click(queryByText('[noThanks]'));
await waitFor(() => {
expect(props.setParticipateInMetaMetrics).toHaveBeenCalledWith(false);
expect(props.hideModal).toHaveBeenCalled();
});
});
it('passes true to setParticipateInMetaMetrics and hides modal', async () => {
const { queryByText } = renderWithProvider(
<MetaMetricsOptIn.WrappedComponent {...props} />,
);
fireEvent.click(queryByText('[affirmAgree]'));
await waitFor(() => {
expect(props.setParticipateInMetaMetrics).toHaveBeenCalledWith(true);
expect(props.hideModal).toHaveBeenCalled();
});
});
});