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';
|
|
|
|
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', () => {
|
|
|
|
it('should render correctly when threeBoxFeatureFlag', () => {
|
2019-05-08 20:57:21 +02:00
|
|
|
const root = shallow(
|
2020-01-14 22:15:54 +01:00
|
|
|
<AdvancedTab
|
|
|
|
ipfsGateway=""
|
2020-08-14 13:47:02 +02:00
|
|
|
setAutoLockTimeLimit={() => undefined}
|
|
|
|
setIpfsGateway={() => undefined}
|
|
|
|
setShowFiatConversionOnTestnetsPreference={() => undefined}
|
|
|
|
setThreeBoxSyncingPermission={() => undefined}
|
2020-01-14 22:15:54 +01:00
|
|
|
threeBoxDisabled
|
|
|
|
threeBoxSyncingAllowed={false}
|
|
|
|
/>,
|
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-04-15 20:01:46 +02:00
|
|
|
expect(root.find('.settings-page__content-row')).toHaveLength(10);
|
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-02-04 19:15:23 +01:00
|
|
|
const setAutoLockTimeLimitSpy = sinon.spy();
|
2019-05-08 20:57:21 +02:00
|
|
|
const root = shallow(
|
|
|
|
<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}
|
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-02-04 19:15:23 +01:00
|
|
|
const autoTimeout = root.find('.settings-page__content-row').at(7);
|
|
|
|
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
|
|
|
});
|
|
|
|
});
|