2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import { mount } from 'enzyme';
|
2021-03-16 22:00:08 +01:00
|
|
|
import SecurityTab from './security-tab.container';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('Security Tab', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
let wrapper;
|
2020-01-30 20:34:45 +01:00
|
|
|
|
|
|
|
const props = {
|
|
|
|
revealSeedConfirmation: sinon.spy(),
|
|
|
|
showClearApprovalModal: sinon.spy(),
|
|
|
|
setParticipateInMetaMetrics: sinon.spy(),
|
|
|
|
displayWarning: sinon.spy(),
|
2021-04-15 20:01:46 +02:00
|
|
|
showIncomingTransactions: false,
|
2020-01-30 20:34:45 +01:00
|
|
|
setShowIncomingTransactionsFeatureFlag: sinon.spy(),
|
|
|
|
history: {
|
|
|
|
push: sinon.spy(),
|
|
|
|
},
|
|
|
|
privacyMode: true,
|
|
|
|
warning: '',
|
|
|
|
participateInMetaMetrics: false,
|
2020-02-27 07:29:41 +01:00
|
|
|
setUsePhishDetect: sinon.spy(),
|
|
|
|
usePhishDetect: true,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
beforeEach(() => {
|
2020-11-03 00:41:28 +01:00
|
|
|
wrapper = mount(<SecurityTab.WrappedComponent {...props} />, {
|
|
|
|
context: {
|
|
|
|
t: (str) => str,
|
|
|
|
metricsEvent: () => undefined,
|
2020-07-14 17:20:41 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('navigates to reveal seed words page', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const seedWords = wrapper.find('.button.btn-danger.btn--large');
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
seedWords.simulate('click');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.history.push.calledOnce).toStrictEqual(true);
|
|
|
|
expect(props.history.push.getCall(0).args[0]).toStrictEqual('/seed');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('toggles incoming txs', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const incomingTxs = wrapper.find({ type: 'checkbox' }).at(0);
|
|
|
|
incomingTxs.simulate('click');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
|
|
|
props.setShowIncomingTransactionsFeatureFlag.calledOnce,
|
|
|
|
).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('toggles phishing detection', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const phishDetect = wrapper.find({ type: 'checkbox' }).at(1);
|
|
|
|
phishDetect.simulate('click');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.setUsePhishDetect.calledOnce).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-02-27 07:29:41 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('toggles metaMetrics', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const metaMetrics = wrapper.find({ type: 'checkbox' }).at(2);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
metaMetrics.simulate('click');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.setParticipateInMetaMetrics.calledOnce).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|