2020-12-06 14:51:48 -08:00
|
|
|
// Public npm libraries
|
2025-11-16 13:37:04 -08:00
|
|
|
import assert from 'assert'
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
import sinon from 'sinon'
|
2020-12-06 14:51:48 -08:00
|
|
|
|
|
|
|
|
// Unit under test (uut)
|
2025-11-16 13:37:04 -08:00
|
|
|
import BCHJS from '../../src/bch-js.js'
|
2020-12-06 14:51:48 -08:00
|
|
|
// const bchjs = new BCHJS()
|
|
|
|
|
let bchjs
|
|
|
|
|
|
2021-01-02 15:41:12 -08:00
|
|
|
describe('#Generating', () => {
|
2020-12-06 14:51:48 -08:00
|
|
|
beforeEach(() => {
|
|
|
|
|
bchjs = new BCHJS()
|
|
|
|
|
})
|
|
|
|
|
|
2021-01-02 15:41:12 -08:00
|
|
|
describe('#generateToAddress', () => {
|
2020-12-06 14:51:48 -08:00
|
|
|
let sandbox
|
|
|
|
|
beforeEach(() => (sandbox = sinon.createSandbox()))
|
|
|
|
|
afterEach(() => sandbox.restore())
|
|
|
|
|
|
2021-01-02 15:41:12 -08:00
|
|
|
it('should generate', done => {
|
2020-12-06 14:51:48 -08:00
|
|
|
const data = []
|
2025-11-16 13:47:24 -08:00
|
|
|
const resolved = new Promise(resolve => resolve({ data }))
|
2021-01-02 15:41:12 -08:00
|
|
|
sandbox.stub(axios, 'post').returns(resolved)
|
2020-12-06 14:51:48 -08:00
|
|
|
|
|
|
|
|
bchjs.Generating.generateToAddress(
|
|
|
|
|
1,
|
2021-01-02 15:41:12 -08:00
|
|
|
'bitcoincash:qrdka2205f4hyukutc2g0s6lykperc8nsu5u2ddpqf'
|
2020-12-06 14:51:48 -08:00
|
|
|
)
|
|
|
|
|
.then(result => {
|
2021-01-02 16:39:44 -08:00
|
|
|
assert.deepStrictEqual(data, result)
|
2020-12-06 14:51:48 -08:00
|
|
|
})
|
|
|
|
|
.then(done, done)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|