Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/computed/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ComputedTransaction = store => {
t.confirmationsLabel = t.confirmations.toString();
}
});
return all;
return all.slice(0, 100);
}),
});
};
Expand Down
31 changes: 22 additions & 9 deletions test/unit/computed/transaction.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ import ComputedTransaction from '../../../src/computed/transaction';

describe('Computed Transactions Unit Tests', () => {
let store;
const bitcoinTransaction = {
id: '0',
type: 'bitcoin',
amount: 923456,
fee: 8250,
confirmations: 0,
status: 'unconfirmed',
date: new Date(),
};

beforeEach(() => {
store = new Store();
store.transactions.push({
id: '0',
type: 'bitcoin',
amount: 923456,
fee: 8250,
confirmations: 0,
status: 'unconfirmed',
date: new Date(),
});
store.transactions.push(bitcoinTransaction);
store.payments.push({
id: '1',
type: 'lightning',
Expand Down Expand Up @@ -68,5 +69,17 @@ describe('Computed Transactions Unit Tests', () => {
expect(tx.amountLabel, 'to match', /63[,.]67/);
expect(tx.feeLabel, 'to match', /0[,.]57/);
});

it('should limit transactions to last 100', () => {
store.payments = null;
store.invoices = null;
store.transactions = [];
const TRANSACTIONS_COUNT = 101;
[...Array(TRANSACTIONS_COUNT)].forEach(() =>
store.transactions.push(bitcoinTransaction)
);
ComputedTransaction(store);
expect(store.computedTransactions.length, 'to equal', 100);
});
});
});