Files
bch-js/test/integration/price.js
T

59 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-01-02 15:41:12 -08:00
const assert = require('chai').assert
const BCHJS = require('../../src/bch-js')
2020-07-27 21:32:51 -07:00
const bchjs = new BCHJS()
2021-01-02 15:41:12 -08:00
describe('#price', () => {
beforeEach(async () => {
if (process.env.IS_USING_FREE_TIER) await sleep(1000)
})
2021-01-02 15:41:12 -08:00
describe('#current', () => {
describe('#single currency', () => {
it('should get current price for single currency', async () => {
const result = await bchjs.Price.current('usd')
2020-07-27 21:32:51 -07:00
assert.notEqual(0, result)
})
})
})
2021-01-02 15:41:12 -08:00
describe('#getUsd', () => {
it('should get the USD price of BCH', async () => {
const result = await bchjs.Price.getUsd()
// console.log(result)
2020-10-20 18:18:18 -07:00
assert.isNumber(result)
})
})
2021-01-02 15:41:12 -08:00
describe('#getBchaUsd', () => {
it('should get the USD price of BCHA', async () => {
2020-11-17 14:41:04 -08:00
const result = await bchjs.Price.getBchaUsd()
console.log(result)
assert.isNumber(result)
})
})
2021-03-04 15:14:46 -04:00
describe('#getBchUsd', () => {
it('should get the USD price of BCH', async () => {
const result = await bchjs.Price.getBchUsd()
console.log(result)
assert.isNumber(result)
})
})
2020-11-17 14:41:04 -08:00
2021-01-02 15:41:12 -08:00
describe('#rates', () => {
it('should get the price of BCH in several currencies', async () => {
2020-10-20 18:18:18 -07:00
const result = await bchjs.Price.rates()
// console.log(result)
2021-01-02 15:41:12 -08:00
assert.property(result, 'USD')
assert.property(result, 'CAD')
})
})
2020-07-27 21:32:51 -07:00
})
2021-01-02 15:41:12 -08:00
function sleep (ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}