fixing unit tests

This commit is contained in:
Chris Troutner
2025-11-17 10:36:14 -08:00
parent 2dad11180b
commit b66ff3cb59
2 changed files with 9 additions and 41 deletions
-10
View File
@@ -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
View File
@@ -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