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

Commit 7a85078

Browse files
committed
Add balanceLabel in ComputedWallet
1 parent 415e00c commit 7a85078

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/computed/wallet.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const ComputedWallet = store => {
1616
get walletAddressUri() {
1717
return store.walletAddress ? `bitcoin:${store.walletAddress}` : '';
1818
},
19+
get balanceLabel() {
20+
return toAmountLabel(store.balanceSatoshis, store.settings);
21+
},
1922
get totalBalanceSatoshis() {
2023
const {
2124
balanceSatoshis,

test/unit/computed/wallet.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe('Computed Wallet Unit Tests', () => {
1313
store.channelBalanceForceClosingSatoshis = 0;
1414
ComputedWallet(store);
1515
expect(store.walletAddressUri, 'to equal', '');
16+
expect(store.balanceLabel, 'to match', /0[,.]00/);
1617
expect(store.totalBalanceSatoshis, 'to equal', 0);
1718
expect(store.totalBalanceLabel, 'to match', /0[,.]00/);
1819
expect(store.unitFiatLabel, 'to equal', '$');
@@ -40,6 +41,7 @@ describe('Computed Wallet Unit Tests', () => {
4041
store.channelBalanceSatoshis = 10000;
4142
store.channelBalanceForceClosingSatoshis = 100;
4243
ComputedWallet(store);
44+
expect(store.balanceLabel, 'to match', /3[,.]447[,.]56/);
4345
expect(store.totalBalanceSatoshis, 'to equal', 100010100);
4446
expect(store.totalBalanceLabel, 'to match', /6[,.]895[,.]82/);
4547
expect(store.unitFiatLabel, 'to equal', '$');
@@ -56,6 +58,7 @@ describe('Computed Wallet Unit Tests', () => {
5658
store.channelBalanceForceClosingSatoshis = 100;
5759
store.settings.unit = 'bit';
5860
ComputedWallet(store);
61+
expect(store.balanceLabel, 'to match', /500[,.]000[,.]01/);
5962
expect(store.totalBalanceSatoshis, 'to equal', 100010101);
6063
expect(store.totalBalanceLabel, 'to match', /1[,.]000[,.]101[,.]01/);
6164
expect(store.unitFiatLabel, 'to equal', 'bits');

0 commit comments

Comments
 (0)