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