2020-01-30 20:34:45 +01:00
|
|
|
import React from 'react'
|
|
|
|
import assert from 'assert'
|
|
|
|
import { shallow } from 'enzyme'
|
|
|
|
import withTokenTracker from '../with-token-tracker.component'
|
|
|
|
import TokenBalance from '../../../../components/ui/token-balance/token-balance.component'
|
|
|
|
// import sinon from 'sinon'
|
|
|
|
import TokenTracker from 'eth-token-tracker'
|
|
|
|
|
|
|
|
const { createTestProviderTools } = require('../../../../../../test/stub/provider')
|
|
|
|
|
|
|
|
const provider = createTestProviderTools({ scaffold: {} }).provider
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('WithTokenTracker HOC', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
let wrapper
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
beforeEach(function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
const TokenTracker = withTokenTracker(TokenBalance)
|
|
|
|
wrapper = shallow(
|
|
|
|
<TokenTracker
|
|
|
|
userAddress="0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
|
|
|
|
token={
|
|
|
|
{
|
|
|
|
address: 'test',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('#setError', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
wrapper.instance().setError('test')
|
|
|
|
assert.equal(wrapper.props().error, 'test')
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('#updateBalance', function () {
|
2020-01-30 20:34:45 +01:00
|
|
|
wrapper.instance().tracker = new TokenTracker({
|
|
|
|
provider,
|
|
|
|
})
|
|
|
|
wrapper.instance().updateBalance([{ string: 'test string', symbol: 'test symbol' }])
|
|
|
|
assert.equal(wrapper.props().string, 'test string')
|
|
|
|
assert.equal(wrapper.props().symbol, 'test symbol')
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|