2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
2022-08-09 17:37:29 +02:00
|
|
|
import { fireEvent, screen } from '@testing-library/react';
|
|
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
2021-03-16 22:00:08 +01:00
|
|
|
import MetaMetricsOptIn from './metametrics-opt-in.container';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('MetaMetricsOptIn', () => {
|
|
|
|
it('opt out of MetaMetrics', () => {
|
2020-02-11 17:51:13 +01:00
|
|
|
const props = {
|
|
|
|
history: {
|
|
|
|
push: sinon.spy(),
|
|
|
|
},
|
|
|
|
setParticipateInMetaMetrics: sinon.stub().resolves(),
|
|
|
|
participateInMetaMetrics: false,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2022-08-09 17:37:29 +02:00
|
|
|
renderWithProvider(<MetaMetricsOptIn.WrappedComponent {...props} />);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-08-09 17:37:29 +02:00
|
|
|
const noThanksButton = screen.getByTestId('page-container-footer-cancel');
|
|
|
|
fireEvent.click(noThanksButton);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
|
|
|
props.setParticipateInMetaMetrics.calledOnceWithExactly(false),
|
|
|
|
).toStrictEqual(true);
|
2022-08-23 22:13:02 +02:00
|
|
|
sinon.resetHistory();
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|