/** * @file * * Mock of Obsidian's `Tasks`, a collector of pending promises that can be awaited together. */ import type { Tasks as TasksOriginal } from 'obsidian'; /** * Mock of Obsidian's `Tasks`: collects promises in memory and awaits them all at once. */ export declare class Tasks { private readonly promises; /** * Creates an empty task collection. */ protected constructor(); /** * Mock-only factory: creates an empty task collection, spyable via `vi.spyOn(Tasks, 'create__')`. * * @returns The new task collection. */ static create__(): Tasks; /** * Mock-only: views a value typed as Obsidian's `Tasks` as this mock. * * @param value - The value typed as the original `Tasks`. * @returns The same object, typed as the mock. */ static fromOriginalType__(value: TasksOriginal): Tasks; /** * Starts a task by calling the callback immediately and collecting the promise it returns. * * @param callback - Starts the task and returns its promise. */ add(callback: () => Promise): void; /** * Collects an already-started promise. * * @param promise - The promise to collect. */ addPromise(promise: Promise): void; /** * Mock-only: views this mock as Obsidian's `Tasks` type. * * @returns The same object, typed as the original `Tasks`. */ asOriginalType__(): TasksOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(Tasks.prototype, 'constructor__')`. */ constructor__(): void; /** * Checks whether no promise has been collected. * * @returns `true` when nothing has been added. */ isEmpty(): boolean; /** * Waits for every collected promise. * * @returns A promise resolving to the array of results, rejecting as soon as any collected promise rejects. */ promise(): Promise; }