Support itbit exchange/ticker. Additions (#232)

* Initial itBit implementation

* Add tests for calculatePrice in exchange/itbit.js

* Add etherium to supported crypto codes in common/itbit.js

* Apply standardjs to itbit files

* itbit trade test. not important

* test getCurrencyRates in ticker/itbit.js
This commit is contained in:
Davit Abulashvili 2018-12-11 13:47:34 +04:00 committed by Josh Harvey
parent 8e1f9e0b83
commit b254f7f2be
12 changed files with 775 additions and 11 deletions

35
test/unit/itbit-trade.js Normal file
View file

@ -0,0 +1,35 @@
import test from 'ava'
import rewire from 'rewire'
import BN from '../../lib/bn'
function rewireTrade (commonMock, calculatePrice = () => Promise.resolve(15)) {
const itbit = rewire('../../lib/plugins/exchange/itbit/itbit')
itbit.__set__('common', commonMock)
itbit.__set__('calculatePrice', calculatePrice)
const trade = itbit.__get__('trade')
return trade
}
test('should handle itbit error response', async t => {
t.plan(1)
const commonMock = {
mock: true,
authRequest () {
return Promise.reject(new Error('The wallet provided does not have the funds required to place the order.'))
},
buildMarket () {
return 'XBTUSD'
}
}
const trade = rewireTrade(commonMock)
trade('buy', { walletId: 'id' }, BN('93410'), 'USD', 'BTC')
.catch(err => {
t.regex(err.message, /wallet provided/g)
})
})