A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/ui/components/app/modals/metametrics-opt-in-modal/metametrics-opt-in-modal.te...

58 lines
1.7 KiB

import React from 'react';
import sinon from 'sinon';
import { mount } from 'enzyme';
import messages from '../../../../../app/_locales/en/messages.json';
import MetaMetricsOptIn from './metametrics-opt-in-modal.container';
describe('MetaMetrics Opt In', () => {
let wrapper;
const props = {
setParticipateInMetaMetrics: sinon.stub().resolves(),
hideModal: sinon.spy(),
participateInMetaMetrics: null,
};
beforeEach(() => {
wrapper = mount(<MetaMetricsOptIn.WrappedComponent {...props} />, {
context: {
metricsEvent: () => undefined,
t: (key) => messages[key].message,
},
});
});
afterEach(() => {
props.setParticipateInMetaMetrics.resetHistory();
props.hideModal.resetHistory();
});
it('passes false to setParticipateInMetaMetrics and hides modal', async () => {
const noThanks = wrapper.find('.btn-default.page-container__footer-button');
noThanks.simulate('click');
expect(await props.setParticipateInMetaMetrics.calledOnce).toStrictEqual(
true,
);
expect(props.setParticipateInMetaMetrics.getCall(0).args[0]).toStrictEqual(
false,
);
expect(props.hideModal.calledOnce).toStrictEqual(true);
});
it('passes true to setParticipateInMetaMetrics and hides modal', async () => {
const affirmAgree = wrapper.find(
'.btn-primary.page-container__footer-button',
);
affirmAgree.simulate('click');
expect(await props.setParticipateInMetaMetrics.calledOnce).toStrictEqual(
true,
);
expect(props.setParticipateInMetaMetrics.getCall(0).args[0]).toStrictEqual(
true,
);
expect(props.hideModal.calledOnce).toStrictEqual(true);
});
});