1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 08:09:15 +01:00
metamask-extension/ui/pages/settings/advanced-tab/advanced-tab.component.test.js

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(12);
});
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);
});
});