2020-01-30 20:34:45 +01:00
|
|
|
import assert from 'assert'
|
2020-08-18 21:18:25 +02:00
|
|
|
import React from 'react'
|
2020-01-30 20:34:45 +01:00
|
|
|
import sinon from 'sinon'
|
|
|
|
import { mount } from 'enzyme'
|
2020-08-19 18:27:05 +02:00
|
|
|
import SecurityTab from '..'
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Security Tab', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
let wrapper
|
|
|
|
|
|
|
|
const props = {
|
|
|
|
revealSeedConfirmation: sinon.spy(),
|
|
|
|
showClearApprovalModal: sinon.spy(),
|
|
|
|
setParticipateInMetaMetrics: sinon.spy(),
|
|
|
|
displayWarning: sinon.spy(),
|
|
|
|
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,
|
2020-01-30 20:34:45 +01:00
|
|
|
}
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
beforeEach(function () {
|
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
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
})
|
2020-01-30 20:34:45 +01:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('navigates to reveal seed words page', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const seedWords = wrapper.find('.button.btn-danger.btn--large')
|
|
|
|
|
|
|
|
seedWords.simulate('click')
|
|
|
|
assert(props.history.push.calledOnce)
|
|
|
|
assert.equal(props.history.push.getCall(0).args[0], '/seed')
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('toggles incoming txs', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const incomingTxs = wrapper.find({ type: 'checkbox' }).at(0)
|
|
|
|
incomingTxs.simulate('click')
|
|
|
|
assert(props.setShowIncomingTransactionsFeatureFlag.calledOnce)
|
|
|
|
})
|
|
|
|
|
2020-02-27 07:29:41 +01:00
|
|
|
it('toggles phishing detection', function () {
|
|
|
|
const phishDetect = wrapper.find({ type: 'checkbox' }).at(1)
|
|
|
|
phishDetect.simulate('click')
|
|
|
|
assert(props.setUsePhishDetect.calledOnce)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('toggles metaMetrics', function () {
|
2020-02-27 07:29:41 +01:00
|
|
|
const metaMetrics = wrapper.find({ type: 'checkbox' }).at(2)
|
2020-01-30 20:34:45 +01:00
|
|
|
|
|
|
|
metaMetrics.simulate('click')
|
|
|
|
assert(props.setParticipateInMetaMetrics.calledOnce)
|
|
|
|
})
|
|
|
|
})
|