2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import { shallow } from 'enzyme';
|
2021-03-16 22:00:08 +01:00
|
|
|
import TextField from '../../../components/ui/text-field';
|
2021-10-21 21:17:03 +02:00
|
|
|
import { LEDGER_TRANSPORT_TYPES } from '../../../../shared/constants/hardware-wallets';
|
2021-10-28 21:31:05 +02:00
|
|
|
import ToggleButton from '../../../components/ui/toggle-button';
|
2021-03-16 22:00:08 +01:00
|
|
|
import AdvancedTab from './advanced-tab.component';
|
2019-05-08 20:57:21 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('AdvancedTab Component', () => {
|
2021-10-28 21:31:05 +02:00
|
|
|
let root;
|
|
|
|
let setAutoLockTimeLimitSpy = sinon.spy();
|
|
|
|
const toggleTestnet = sinon.spy();
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
root = shallow(
|
2020-01-14 22:15:54 +01:00
|
|
|
<AdvancedTab
|
|
|
|
ipfsGateway=""
|
2021-10-28 21:31:05 +02:00
|
|
|
setAutoLockTimeLimit={setAutoLockTimeLimitSpy}
|
2020-08-14 13:47:02 +02:00
|
|
|
setIpfsGateway={() => undefined}
|
|
|
|
setShowFiatConversionOnTestnetsPreference={() => undefined}
|
|
|
|
setThreeBoxSyncingPermission={() => undefined}
|
2021-10-28 21:31:05 +02:00
|
|
|
setShowTestNetworks={toggleTestnet}
|
|
|
|
showTestNetworks={false}
|
2020-01-14 22:15:54 +01:00
|
|
|
threeBoxDisabled
|
|
|
|
threeBoxSyncingAllowed={false}
|
2021-10-21 21:17:03 +02:00
|
|
|
ledgerTransportType={LEDGER_TRANSPORT_TYPES.U2F}
|
2021-05-20 20:28:25 +02:00
|
|
|
setLedgerLivePreference={() => undefined}
|
|
|
|
setDismissSeedBackUpReminder={() => undefined}
|
|
|
|
dismissSeedBackUpReminder={false}
|
2020-01-14 22:15:54 +01:00
|
|
|
/>,
|
2019-05-08 20:57:21 +02:00
|
|
|
{
|
|
|
|
context: {
|
2020-02-15 21:34:12 +01:00
|
|
|
t: (s) => `_${s}`,
|
2019-05-08 20:57:21 +02:00
|
|
|
},
|
2020-07-14 17:20:41 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-10-28 21:31:05 +02:00
|
|
|
});
|
2019-05-08 20:57:21 +02:00
|
|
|
|
2021-10-28 21:31:05 +02:00
|
|
|
it('should render correctly when threeBoxFeatureFlag', () => {
|
|
|
|
expect(root.find('.settings-page__content-row')).toHaveLength(13);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-09-16 19:11:01 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should update autoLockTimeLimit', () => {
|
2021-10-28 21:31:05 +02:00
|
|
|
setAutoLockTimeLimitSpy = sinon.spy();
|
|
|
|
root = shallow(
|
2019-05-08 20:57:21 +02:00
|
|
|
<AdvancedTab
|
2020-01-14 22:15:54 +01:00
|
|
|
ipfsGateway=""
|
2020-01-21 23:09:53 +01:00
|
|
|
setAutoLockTimeLimit={setAutoLockTimeLimitSpy}
|
2020-08-14 13:47:02 +02:00
|
|
|
setIpfsGateway={() => undefined}
|
|
|
|
setShowFiatConversionOnTestnetsPreference={() => undefined}
|
|
|
|
setThreeBoxSyncingPermission={() => undefined}
|
2020-01-14 22:15:54 +01:00
|
|
|
threeBoxDisabled
|
|
|
|
threeBoxSyncingAllowed={false}
|
2021-10-21 21:17:03 +02:00
|
|
|
ledgerTransportType={LEDGER_TRANSPORT_TYPES.U2F}
|
2021-05-20 20:28:25 +02:00
|
|
|
setLedgerLivePreference={() => undefined}
|
|
|
|
setDismissSeedBackUpReminder={() => undefined}
|
|
|
|
dismissSeedBackUpReminder={false}
|
2021-10-28 21:31:05 +02:00
|
|
|
setShowTestNetworks={toggleTestnet}
|
2019-05-08 20:57:21 +02:00
|
|
|
/>,
|
|
|
|
{
|
|
|
|
context: {
|
2020-02-15 21:34:12 +01:00
|
|
|
t: (s) => `_${s}`,
|
2019-05-08 20:57:21 +02:00
|
|
|
},
|
2020-07-14 17:20:41 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-05-08 20:57:21 +02:00
|
|
|
|
2021-10-28 21:31:05 +02:00
|
|
|
const autoTimeout = root.find('.settings-page__content-row').at(8);
|
2021-02-04 19:15:23 +01:00
|
|
|
const textField = autoTimeout.find(TextField);
|
2019-05-08 20:57:21 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
textField.props().onChange({ target: { value: 1440 } });
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(root.state().autoLockTimeLimit).toStrictEqual(1440);
|
2019-05-08 20:57:21 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
autoTimeout.find('.settings-tab__rpc-save-button').simulate('click');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(setAutoLockTimeLimitSpy.args[0][0]).toStrictEqual(1440);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2021-10-28 21:31:05 +02:00
|
|
|
|
|
|
|
it('should toggle show test networks', () => {
|
|
|
|
const testNetworks = root.find('.settings-page__content-row').at(6);
|
|
|
|
const toggleButton = testNetworks.find(ToggleButton);
|
|
|
|
toggleButton.first().simulate('toggle');
|
|
|
|
expect(toggleTestnet.calledOnce).toStrictEqual(true);
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|