Skip to content

Commit fae6f66

Browse files
committed
fix(sdk-core): fix broken mocking for unit tests
TICKET: BTC-1527
1 parent 667c366 commit fae6f66

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

modules/bitgo/test/v2/unit/wallet.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,6 @@ describe('V2 Wallet:', function () {
15001500
it('should pass unspents parameter when calling fanout unspents', async function () {
15011501
const path = `/api/v2/${wallet.coin()}/wallet/${wallet.id()}/fanoutUnspents`;
15021502
const response = nock(bgUrl)
1503-
.persist()
15041503
.post(path, _.matches({ unspents })) // use _.matches to do a partial match on request body object instead of strict matching
15051504
.reply(200);
15061505

@@ -1516,13 +1515,18 @@ describe('V2 Wallet:', function () {
15161515

15171516
it('should only build tx (not sign/send) while fanning out unspents', async function () {
15181517
const path = `/api/v2/${wallet.coin()}/wallet/${wallet.id()}/fanoutUnspents`;
1519-
const response = nock(bgUrl).persist().post(path, _.matches({ unspents })).reply(200);
1518+
const response = nock(bgUrl).post(path, _.matches({ unspents })).reply(200);
15201519

15211520
const unusedNocks = nock(bgUrl);
15221521
unusedNocks.get(`/api/v2/${wallet.coin()}/key/${wallet.keyIds()[0]}`).reply(200);
15231522
unusedNocks.post(`/api/v2/${wallet.coin()}/wallet/${wallet.id()}/tx/send`).reply(200);
15241523

1525-
await wallet.fanoutUnspents({ address, unspents }, ManageUnspentsOptions.BUILD_ONLY);
1524+
try {
1525+
await wallet.fanoutUnspents({ address, unspents }, ManageUnspentsOptions.BUILD_ONLY);
1526+
} catch (e) {
1527+
// the fanoutUnspents method will probably throw an exception for not having all of the correct nocks
1528+
// we only care about /fanoutUnspents and whether unspents is an allowed parameter
1529+
}
15261530

15271531
response.isDone().should.be.true();
15281532
unusedNocks.pendingMocks().length.should.eql(2);
@@ -1585,6 +1589,7 @@ describe('V2 Wallet:', function () {
15851589
await wallet.consolidateUnspents({ bulk: true, walletPassphrase });
15861590

15871591
nocks.forEach((n) => {
1592+
console.log(n);
15881593
n.isDone().should.be.true();
15891594
});
15901595
});

0 commit comments

Comments
 (0)