2018-01-30 22:26:37 +01:00
|
|
|
const assert = require('assert')
|
|
|
|
const { createMockStore } = require('redux-test-utils')
|
|
|
|
const h = require('react-hyperscript')
|
2018-09-24 18:28:04 +02:00
|
|
|
const { shallowWithStore } = require('../../lib/render-helpers')
|
2018-02-08 00:20:11 +01:00
|
|
|
const AddTokenScreen = require('../../../old-ui/app/add-token')
|
2018-01-30 22:26:37 +01:00
|
|
|
|
2018-01-30 22:29:05 +01:00
|
|
|
describe('Add Token Screen', function () {
|
2018-01-30 22:26:37 +01:00
|
|
|
let addTokenComponent, store, component
|
|
|
|
const mockState = {
|
|
|
|
metamask: {
|
|
|
|
identities: {
|
|
|
|
'0x7d3517b0d011698406d6e0aed8453f0be2697926': {
|
|
|
|
'address': '0x7d3517b0d011698406d6e0aed8453f0be2697926',
|
|
|
|
'name': 'Add Token Name',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
beforeEach(function () {
|
|
|
|
store = createMockStore(mockState)
|
|
|
|
component = shallowWithStore(h(AddTokenScreen), store)
|
|
|
|
addTokenComponent = component.dive()
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('#ValidateInputs', function () {
|
|
|
|
|
|
|
|
it('Default State', function () {
|
|
|
|
addTokenComponent.instance().validateInputs()
|
|
|
|
const state = addTokenComponent.state()
|
|
|
|
assert.equal(state.warning, 'Address is invalid.')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Address is a Metamask Identity', function () {
|
|
|
|
addTokenComponent.setState({
|
|
|
|
address: '0x7d3517b0d011698406d6e0aed8453f0be2697926',
|
|
|
|
})
|
|
|
|
addTokenComponent.instance().validateInputs()
|
|
|
|
const state = addTokenComponent.state()
|
|
|
|
assert.equal(state.warning, 'Personal address detected. Input the token contract address.')
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|