feat(income): add account income analytics API
This commit is contained in:
@@ -254,6 +254,50 @@ describe('BrokerageOperationsService', () => {
|
||||
expect(tbank.getOperationsByCursor).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('collects every cursor page and rejects a malformed continuation cursor', async () => {
|
||||
tbank.getOperationsByCursor
|
||||
.mockResolvedValueOnce({ hasNext: true, nextCursor: 'next', items: [] })
|
||||
.mockResolvedValueOnce({ hasNext: false, items: [] });
|
||||
|
||||
await expect(
|
||||
service.collectRanges('user', 'account', [
|
||||
{ from: '2026-01-01', to: '2026-01-31' },
|
||||
]),
|
||||
).resolves.toMatchObject({
|
||||
pages: [[{ hasNext: true }, { hasNext: false }]],
|
||||
});
|
||||
|
||||
tbank.getOperationsByCursor.mockReset();
|
||||
tbank.getOperationsByCursor.mockResolvedValue({
|
||||
hasNext: true,
|
||||
nextCursor: 'same',
|
||||
items: [],
|
||||
});
|
||||
await expect(
|
||||
service.collectRanges('user', 'account', [
|
||||
{ from: '2026-02-01', to: '2026-02-28' },
|
||||
]),
|
||||
).rejects.toMatchObject({ response: { code: 'TBANK_UNAVAILABLE' } });
|
||||
});
|
||||
|
||||
it('collects an in-progress Moscow day only through the current instant', async () => {
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date('2026-08-27T21:44:18.510Z'));
|
||||
|
||||
await service.collectRanges('user', 'account', [
|
||||
{ from: '2026-08-01', to: '2026-08-28' },
|
||||
]);
|
||||
|
||||
expect(tbank.getOperationsByCursor).toHaveBeenCalledWith(
|
||||
'token',
|
||||
expect.objectContaining({
|
||||
from: { seconds: '1785531600' },
|
||||
to: { seconds: '1787867058' },
|
||||
limit: 1000,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('evicts the least recently used ledger page after one hundred entries', async () => {
|
||||
for (let index = 0; index < 100; index += 1)
|
||||
await service.get('user', 'account', { cursor: String(index) });
|
||||
|
||||
Reference in New Issue
Block a user