Commit 04b678ea authored by Tankred Hase's avatar Tankred Hase

Implement channelStatus from computed sat channel balances

parent f2b8d059
......@@ -78,6 +78,20 @@ const ComputedChannel = store => {
get showChannelAlert() {
return (store.channels || []).length === 0;
},
get channelStatus() {
const {
channelBalanceOpenSatoshis: opened,
channelBalanceInactiveSatoshis: inactive,
channelBalancePendingSatoshis: pending,
} = store;
return opened
? 'success'
: inactive
? 'inactive'
: pending
? 'info'
: 'error';
},
});
};
......
......@@ -58,6 +58,7 @@ describe('Computed Channels Unit Tests', () => {
expect(store.channelBalancePendingLabel, 'to equal', '0');
expect(store.channelBalanceClosingLabel, 'to equal', '0');
expect(store.showChannelAlert, 'to equal', true);
expect(store.channelStatus, 'to equal', 'error');
});
it('should aggregate open and pending channels', () => {
......@@ -88,6 +89,7 @@ describe('Computed Channels Unit Tests', () => {
expect(store.channelBalancePendingLabel, 'to match', /0[,.]006/);
expect(store.channelBalanceClosingLabel, 'to match', /0[,.]005/);
expect(store.showChannelAlert, 'to equal', false);
expect(store.channelStatus, 'to equal', 'success');
});
it('should channel values in usd', () => {
......@@ -104,5 +106,17 @@ describe('Computed Channels Unit Tests', () => {
expect(store.channelBalancePendingLabel, 'to match', /41[,.]37/);
expect(store.channelBalanceClosingLabel, 'to match', /34[,.]48/);
});
it('should display pending status', () => {
store.channels = null;
ComputedChannel(store);
expect(store.channelStatus, 'to equal', 'info');
});
it('should display inactive status', () => {
store.channels[0].active = false;
ComputedChannel(store);
expect(store.channelStatus, 'to equal', 'inactive');
});
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment