mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
import chai from 'chai'
|
|
import BCHJS from '../../src/bch-js.js'
|
|
const { assert } = chai
|
|
const bchjs = new BCHJS()
|
|
|
|
describe('#price', () => {
|
|
beforeEach(async () => {
|
|
if (process.env.IS_USING_FREE_TIER) await sleep(1500)
|
|
})
|
|
|
|
// describe('#current', () => {
|
|
// describe('#single currency', () => {
|
|
// it('should get current price for single currency', async () => {
|
|
// const result = await bchjs.Price.current('usd')
|
|
// assert.notEqual(0, result)
|
|
// })
|
|
// })
|
|
// })
|
|
|
|
describe('#getUsd', () => {
|
|
it('should get the USD price of BCH', async () => {
|
|
const result = await bchjs.Price.getUsd()
|
|
// console.log(result)
|
|
|
|
assert.isNumber(result)
|
|
})
|
|
})
|
|
|
|
describe('#getBchaUsd', () => {
|
|
it('should get the USD price of BCHA', async () => {
|
|
const result = await bchjs.Price.getBchaUsd()
|
|
console.log(result)
|
|
|
|
assert.isNumber(result)
|
|
})
|
|
})
|
|
|
|
describe('#getBchUsd', () => {
|
|
it('should get the USD price of BCH', async () => {
|
|
const result = await bchjs.Price.getBchUsd()
|
|
console.log(result)
|
|
|
|
assert.isNumber(result)
|
|
})
|
|
})
|
|
|
|
describe('#rates', () => {
|
|
it('should get the price of BCH in several currencies', async () => {
|
|
const result = await bchjs.Price.rates()
|
|
// console.log(result)
|
|
|
|
assert.property(result, 'USD')
|
|
assert.property(result, 'CAD')
|
|
})
|
|
})
|
|
|
|
describe('#getPsffppPrice', () => {
|
|
it('should get the price of BCH in several currencies', async () => {
|
|
const result = await bchjs.Price.getPsffppPrice()
|
|
// console.log(result)
|
|
|
|
assert.isNumber(result)
|
|
})
|
|
})
|
|
})
|
|
|
|
function sleep (ms) {
|
|
return new Promise(resolve => setTimeout(resolve, ms))
|
|
}
|