1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-04 23:14:56 +01:00
metamask-extension/ui/components/app/modals/metametrics-opt-in-modal/metametrics-opt-in-modal.test.js
2022-03-29 08:46:24 -05:00

60 lines
1.7 KiB
JavaScript

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: {
trackEvent: () => 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-secondary.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);
});
});