2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import configureMockStore from 'redux-mock-store';
|
2021-04-28 21:53:59 +02:00
|
|
|
import { mountWithRouter } 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
|
|
|
};
|
2020-02-11 17:51:13 +01:00
|
|
|
const store = configureMockStore()({
|
|
|
|
metamask: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-02-11 17:51:13 +01:00
|
|
|
const wrapper = mountWithRouter(
|
2020-11-03 00:41:28 +01:00
|
|
|
<MetaMetricsOptIn.WrappedComponent {...props} />,
|
|
|
|
store,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-11-03 00:41:28 +01:00
|
|
|
const noThanksButton = wrapper.find(
|
|
|
|
'.btn-default.page-container__footer-button',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
noThanksButton.simulate('click');
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
|
|
|
props.setParticipateInMetaMetrics.calledOnceWithExactly(false),
|
|
|
|
).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
props.setParticipateInMetaMetrics.resetHistory();
|
|
|
|
});
|
|
|
|
});
|