chore: Fixed tests

This commit is contained in:
Simeon Radivoev 2026-05-15 15:07:51 +03:00
parent 9141fb35d4
commit 5593985884
Signed by: simeonradivoev
GPG key ID: 7611A451D2A5D37A
13 changed files with 139 additions and 66 deletions

View file

@ -91,6 +91,11 @@ export class TaskQueue
return this.activeQueue.length > 0;
}
public hasQueued ()
{
return this.queue && this.queue.length > 0;
}
public hasActiveOfType (type: any)
{
for (const entry of this.activeQueue)
@ -109,6 +114,30 @@ export class TaskQueue
return job?.promise.promise ?? Promise.resolve();
}
public waitForAll ()
{
return new Promise((resolve) =>
{
if (!this.hasActive())
{
resolve(true);
return;
}
const handleEnded = () =>
{
if (!this.hasActive() && !this.hasQueued())
{
resolve(true);
this.events?.removeListener('ended', handleEnded);
this.events?.removeListener('abort', handleEnded);
}
};
this.events?.on('ended', handleEnded);
this.events?.on('abort', handleEnded);
});
}
public cancelJob (id: string)
{
const job = this.queue?.find(j => j.id === id)