mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
fixing unit tests
This commit is contained in:
@@ -58,16 +58,6 @@ describe('#price', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('#getBchaUsd', () => {
|
||||
it('should get the USD price of BCHA', async () => {
|
||||
sandbox.stub(bchjs.Price.axios, 'get').resolves({ data: { usd: 18.87 } })
|
||||
|
||||
const result = await bchjs.Price.getBchaUsd()
|
||||
// console.log(result)
|
||||
|
||||
assert.isNumber(result)
|
||||
})
|
||||
})
|
||||
describe('#getBchUsd', () => {
|
||||
it('should get the USD price of BCH', async () => {
|
||||
sandbox.stub(bchjs.Price.axios, 'get').resolves({ data: { usd: 510.39 } })
|
||||
|
||||
+9
-31
@@ -1,40 +1,18 @@
|
||||
import assert from 'assert'
|
||||
/*
|
||||
Unit tests for util.js library.
|
||||
*/
|
||||
|
||||
// Global npm libraries
|
||||
import chai from 'chai'
|
||||
import axios from 'axios'
|
||||
|
||||
// Local libraries
|
||||
import BCHJS from '../../src/bch-js.js'
|
||||
import sinon from 'sinon'
|
||||
// import sinon from 'sinon'
|
||||
const { assert: assert2 } = chai
|
||||
|
||||
const bchjs = new BCHJS()
|
||||
|
||||
describe('#Util', () => {
|
||||
describe('#validateAddress', () => {
|
||||
let sandbox
|
||||
beforeEach(() => (sandbox = sinon.createSandbox()))
|
||||
afterEach(() => sandbox.restore())
|
||||
|
||||
it('should validate address', done => {
|
||||
const data = {
|
||||
isvalid: true,
|
||||
address: 'bitcoincash:qpz7qtkuyhrsz4qmnnrvf8gz9zd0u9v7eqsewyk4w5',
|
||||
scriptPubKey: '76a91445e02edc25c701541b9cc6c49d02289afe159ec888ac',
|
||||
ismine: false,
|
||||
iswatchonly: false,
|
||||
isscript: false
|
||||
}
|
||||
|
||||
const resolved = new Promise(resolve => resolve({ data }))
|
||||
sandbox.stub(axios, 'get').returns(resolved)
|
||||
|
||||
bchjs.Util.validateAddress(
|
||||
'bitcoincash:qpz7qtkuyhrsz4qmnnrvf8gz9zd0u9v7eqsewyk4w5'
|
||||
)
|
||||
.then(result => {
|
||||
assert.deepStrictEqual(data, result)
|
||||
})
|
||||
.then(done, done)
|
||||
})
|
||||
})
|
||||
|
||||
describe('#floor8', () => {
|
||||
it('should floor a number to 8 decimals', () => {
|
||||
const num = 1.234567891111
|
||||
|
||||
Reference in New Issue
Block a user