Auto logout after specific time (#6558)
* Add i18n strings * Finish Auto timeout * Fix linter * Fix copies * Add unit test to Advanced Tab component * Add back actions and container * Add basic test to ensure container completeness * No zero, fix linters * restrict negative in inputfeature/default_network_editable
parent
0497d209b2
commit
56ed189aeb
@ -0,0 +1,44 @@ |
||||
import React from 'react' |
||||
import assert from 'assert' |
||||
import sinon from 'sinon' |
||||
import { shallow } from 'enzyme' |
||||
import AdvancedTab from '../advanced-tab.component' |
||||
import TextField from '../../../../components/ui/text-field' |
||||
|
||||
describe('AdvancedTab Component', () => { |
||||
it('should render correctly', () => { |
||||
const root = shallow( |
||||
<AdvancedTab />, |
||||
{ |
||||
context: { |
||||
t: s => `_${s}`, |
||||
}, |
||||
} |
||||
) |
||||
|
||||
assert.equal(root.find('.settings-page__content-row').length, 8) |
||||
}) |
||||
|
||||
it('should update autoLogoutTimeLimit', () => { |
||||
const setAutoLogoutTimeLimitSpy = sinon.spy() |
||||
const root = shallow( |
||||
<AdvancedTab |
||||
setAutoLogoutTimeLimit={setAutoLogoutTimeLimitSpy} |
||||
/>, |
||||
{ |
||||
context: { |
||||
t: s => `_${s}`, |
||||
}, |
||||
} |
||||
) |
||||
|
||||
const autoTimeout = root.find('.settings-page__content-row').last() |
||||
const textField = autoTimeout.find(TextField) |
||||
|
||||
textField.props().onChange({ target: { value: 1440 } }) |
||||
assert.equal(root.state().autoLogoutTimeLimit, 1440) |
||||
|
||||
autoTimeout.find('button').simulate('click') |
||||
assert.equal(setAutoLogoutTimeLimitSpy.args[0][0], 1440) |
||||
}) |
||||
}) |
@ -0,0 +1,46 @@ |
||||
import assert from 'assert' |
||||
import { mapStateToProps, mapDispatchToProps } from '../advanced-tab.container' |
||||
|
||||
const defaultState = { |
||||
appState: { |
||||
warning: null, |
||||
}, |
||||
metamask: { |
||||
featureFlags: { |
||||
sendHexData: false, |
||||
advancedInlineGas: false, |
||||
}, |
||||
preferences: { |
||||
autoLogoutTimeLimit: 0, |
||||
showFiatInTestnets: false, |
||||
useNativeCurrencyAsPrimaryCurrency: true, |
||||
}, |
||||
}, |
||||
} |
||||
|
||||
describe('AdvancedTab Container', () => { |
||||
it('should map state to props correctly', () => { |
||||
const props = mapStateToProps(defaultState) |
||||
const expected = { |
||||
warning: null, |
||||
sendHexData: false, |
||||
advancedInlineGas: false, |
||||
showFiatInTestnets: false, |
||||
autoLogoutTimeLimit: 0, |
||||
} |
||||
|
||||
assert.deepEqual(props, expected) |
||||
}) |
||||
|
||||
it('should map dispatch to props correctly', () => { |
||||
const props = mapDispatchToProps(() => 'mockDispatch') |
||||
|
||||
assert.ok(typeof props.setHexDataFeatureFlag === 'function') |
||||
assert.ok(typeof props.setRpcTarget === 'function') |
||||
assert.ok(typeof props.displayWarning === 'function') |
||||
assert.ok(typeof props.showResetAccountConfirmationModal === 'function') |
||||
assert.ok(typeof props.setAdvancedInlineGasFeatureFlag === 'function') |
||||
assert.ok(typeof props.setShowFiatConversionOnTestnetsPreference === 'function') |
||||
assert.ok(typeof props.setAutoLogoutTimeLimit === 'function') |
||||
}) |
||||
}) |
Loading…
Reference in new issue