Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 61d6801

Browse files
committed
Add unit test in case of fee estimate error
1 parent 1904c61 commit 61d6801

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

test/unit/action/payment.spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,30 @@ describe('Action Payments Unit Tests', () => {
151151
expect(store.payment.fee, 'to match', /^0[,.]0{5}1{1}$/);
152152
});
153153

154-
it('should set response to null on error', async () => {
154+
it('should set nothing on decode error', async () => {
155155
grpc.sendCommand.withArgs('decodePayReq').rejects(new Error('Boom!'));
156156
const isValid = await payment.decodeInvoice({ invoice: 'some-invoice' });
157157
expect(isValid, 'to be', false);
158158
expect(store.payment.amount, 'to be', '');
159159
expect(store.payment.note, 'to be', '');
160+
expect(store.payment.fee, 'to be', '');
160161
expect(logger.info, 'was called once');
161162
});
163+
164+
it('should set no fee on query route error', async () => {
165+
grpc.sendCommand.withArgs('decodePayReq').resolves({
166+
num_satoshis: '1700',
167+
description: 'foo',
168+
destination: 'bar',
169+
});
170+
grpc.sendCommand.withArgs('queryRoutes').rejects(new Error('Boom!'));
171+
const isValid = await payment.decodeInvoice({ invoice: 'some-invoice' });
172+
expect(isValid, 'to be', true);
173+
expect(store.payment.amount, 'to match', /^0[,.]0{4}1{1}7{1}$/);
174+
expect(store.payment.note, 'to be', 'foo');
175+
expect(store.payment.fee, 'to be', '');
176+
expect(logger.error, 'was called once');
177+
});
162178
});
163179

164180
describe('payBitcoin()', () => {

0 commit comments

Comments
 (0)