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

Commit 8e5c8cc

Browse files
authored
Merge pull request #641 from erkarl/limit-transactions-history
Limit transactions list to last 100 transactions
2 parents ba37ff8 + 1b7babd commit 8e5c8cc

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

src/computed/transaction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const ComputedTransaction = store => {
2828
t.confirmationsLabel = t.confirmations.toString();
2929
}
3030
});
31-
return all;
31+
return all.slice(0, 100);
3232
}),
3333
});
3434
};

test/unit/computed/transaction.spec.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ import ComputedTransaction from '../../../src/computed/transaction';
33

44
describe('Computed Transactions Unit Tests', () => {
55
let store;
6+
const bitcoinTransaction = {
7+
id: '0',
8+
type: 'bitcoin',
9+
amount: 923456,
10+
fee: 8250,
11+
confirmations: 0,
12+
status: 'unconfirmed',
13+
date: new Date(),
14+
};
615

716
beforeEach(() => {
817
store = new Store();
9-
store.transactions.push({
10-
id: '0',
11-
type: 'bitcoin',
12-
amount: 923456,
13-
fee: 8250,
14-
confirmations: 0,
15-
status: 'unconfirmed',
16-
date: new Date(),
17-
});
18+
store.transactions.push(bitcoinTransaction);
1819
store.payments.push({
1920
id: '1',
2021
type: 'lightning',
@@ -68,5 +69,17 @@ describe('Computed Transactions Unit Tests', () => {
6869
expect(tx.amountLabel, 'to match', /63[,.]67/);
6970
expect(tx.feeLabel, 'to match', /0[,.]57/);
7071
});
72+
73+
it('should limit transactions to last 100', () => {
74+
store.payments = null;
75+
store.invoices = null;
76+
store.transactions = [];
77+
const TRANSACTIONS_COUNT = 101;
78+
[...Array(TRANSACTIONS_COUNT)].forEach(() =>
79+
store.transactions.push(bitcoinTransaction)
80+
);
81+
ComputedTransaction(store);
82+
expect(store.computedTransactions.length, 'to equal', 100);
83+
});
7184
});
7285
});

0 commit comments

Comments
 (0)