import { type Constructor } from '@poppinss/utils/types'; import type { AllowedEventTypes, BufferedEvent, BufferedEventsList } from './types.ts'; /** * Callback function to narrow down an event from * the events buffer list */ type EventFinderCallback, Event extends keyof EventsList | Constructor> = (event: Event extends keyof EventsList ? BufferedEvent : Event extends Constructor ? BufferedEvent : never) => boolean; /** * Exposes API to filter, find events from the events buffer. */ export declare class EventsBuffer> { #private; constructor(restoreFn: () => void); /** * Track emitted event * * @param event - The event that was emitted * @param data - The data passed with the event */ add(event: Name, data: any): void; /** * Get all the emitted events * * @returns Array of all buffered events */ all(): BufferedEventsList[]; /** * Returns the size of captured events * * @returns The number of captured events */ size(): number; /** * Find if an event was emitted * * @param event - The event to check for * @param finder - Optional callback to filter specific event instances * @returns True if the event was emitted */ exists>(event: Event, finder?: EventFinderCallback): boolean; /** * Find a specific event * * @param event - The event to find * @param finder - Optional callback to filter specific event instances * @returns The found event or null */ find>(event: Event, finder?: EventFinderCallback): (Event extends keyof EventsList ? BufferedEvent : Event extends Constructor ? BufferedEvent : never) | null; /** * Assert a given event has been emitted * * @param event - The event to assert was emitted * @param finder - Optional callback to filter specific event instances * @throws AssertionError if the event was not emitted */ assertEmitted>(event: Event, finder?: EventFinderCallback): void; /** * Assert number of times an event has been emitted * * @param event - The event to check emission count for * @param count - The expected number of emissions * @throws AssertionError if the count doesn't match */ assertEmittedCount>(event: Event, count: number): void; /** * Assert a given event has been not been emitted * * @param event - The event to assert was not emitted * @param finder - Optional callback to filter specific event instances * @throws AssertionError if the event was emitted */ assertNotEmitted>(event: Event, finder?: EventFinderCallback): void; /** * Assert no events have been emitted * * @throws AssertionError if any events were emitted */ assertNoneEmitted(): void; /** * Flush events collected within memory */ flush(): void; [Symbol.dispose](): void; } export {};