1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-05 07:24:56 +01:00
metamask-extension/ui/pages/settings/advanced-tab/advanced-tab.component.test.js
ryanml 6640973858
Fixing jest component test output errors (#11139)
* Adding missing required props to component tests

* Removing unused IntroPopup component

* Mocking useLayoutEffect as useEffect in confirm-page-container-header.component.test.js
2021-05-20 11:28:25 -07:00

66 lines
2.1 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}
useLedgerLive={false}
setLedgerLivePreference={() => undefined}
setDismissSeedBackUpReminder={() => undefined}
dismissSeedBackUpReminder={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}
useLedgerLive={false}
setLedgerLivePreference={() => undefined}
setDismissSeedBackUpReminder={() => undefined}
dismissSeedBackUpReminder={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);
});
});