Skip to content

Commit

Permalink
Add basic test to ensure container completeness
Browse files Browse the repository at this point in the history
  • Loading branch information
chikeichan committed May 7, 2019
1 parent ccd1aba commit 553efd0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ui/app/pages/settings/advanced-tab/advanced-tab.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '../../../store/actions'
import {preferencesSelector} from '../../../selectors/selectors'

const mapStateToProps = state => {
export const mapStateToProps = state => {
const { appState: { warning }, metamask } = state
const {
featureFlags: {
Expand All @@ -31,7 +31,7 @@ const mapStateToProps = state => {
}
}

const mapDispatchToProps = dispatch => {
export const mapDispatchToProps = dispatch => {
return {
setHexDataFeatureFlag: shouldShow => dispatch(setFeatureFlag('sendHexData', shouldShow)),
setRpcTarget: (newRpc, chainId, ticker, nickname) => dispatch(updateAndSetCustomRpc(newRpc, chainId, ticker, nickname)),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react'
import assert from 'assert'
import sinon from 'sinon'
import { mount } from 'enzyme'
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')
})
})

0 comments on commit 553efd0

Please sign in to comment.