1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-04 23:14:56 +01:00
metamask-extension/ui/app/pages/settings/advanced-tab/advanced-tab.component.test.js
2021-05-26 10:33:12 -07:00

58 lines
1.7 KiB
JavaScript

import React from 'react';
import sinon from 'sinon';
import { shallow } from 'enzyme';
import TextField from '../../../components/ui/text-field';
import AdvancedTab from './advanced-tab.component';
describe('AdvancedTab Component', () => {
it('should render correctly when threeBoxFeatureFlag', () => {
const root = shallow(
<AdvancedTab
ipfsGateway=""
setAutoLockTimeLimit={() => undefined}
setIpfsGateway={() => undefined}
setShowFiatConversionOnTestnetsPreference={() => undefined}
setThreeBoxSyncingPermission={() => undefined}
threeBoxDisabled
threeBoxSyncingAllowed={false}
/>,
{
context: {
t: (s) => `_${s}`,
},
},
);
expect(root.find('.settings-page__content-row')).toHaveLength(11);
});
it('should update autoLockTimeLimit', () => {
const setAutoLockTimeLimitSpy = sinon.spy();
const root = shallow(
<AdvancedTab
ipfsGateway=""
setAutoLockTimeLimit={setAutoLockTimeLimitSpy}
setIpfsGateway={() => undefined}
setShowFiatConversionOnTestnetsPreference={() => undefined}
setThreeBoxSyncingPermission={() => undefined}
threeBoxDisabled
threeBoxSyncingAllowed={false}
/>,
{
context: {
t: (s) => `_${s}`,
},
},
);
const autoTimeout = root.find('.settings-page__content-row').at(7);
const textField = autoTimeout.find(TextField);
textField.props().onChange({ target: { value: 1440 } });
expect(root.state().autoLockTimeLimit).toStrictEqual(1440);
autoTimeout.find('.settings-tab__rpc-save-button').simulate('click');
expect(setAutoLockTimeLimitSpy.args[0][0]).toStrictEqual(1440);
});
});