Files
Toju/toju-app/src/app/domains/attachment/domain/logic/attachment-autodownload-concurrency.rules.spec.ts
T
myxeliumandCursor fa45052432 fix: Bug - Sending files and attachment issues
Hydrate playable media after disk receive, relay file-announce to sibling
devices via account_sync, bind DM attachments to pre-allocated message ids,
and improve gallery retry/cancel UX with bounded parallel auto-downloads.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-14 13:05:23 +02:00

30 lines
724 B
TypeScript

import { runTasksWithBoundedConcurrency } from './attachment-autodownload-concurrency.rules';
describe('attachment-autodownload-concurrency.rules', () => {
it('runs tasks with bounded concurrency', async () => {
let active = 0;
let maxActive = 0;
const tasks = Array.from({ length: 6 }, (_, index) => async () => {
active += 1;
maxActive = Math.max(maxActive, active);
await new Promise((resolve) => setTimeout(resolve, 5));
active -= 1;
return index;
});
const results = await runTasksWithBoundedConcurrency(tasks, 2);
expect(results).toEqual([
0,
1,
2,
3,
4,
5
]);
expect(maxActive).toBeLessThanOrEqual(2);
});
});