/** * EventEmitter and EventTarget assertions for Bupkis. * * @packageDocumentation */ import { z } from 'bupkis'; import type { EventEmitterLike, TimeoutOptions, Trigger } from "./types.js"; /** * Asserts that an emitter has at least one listener for the specified event. * * @example * * ```ts * const emitter = new EventEmitter(); * emitter.on('data', () => {}); * expect(emitter, 'to have listener for', 'data'); // passes * ``` */ export declare const hasListenerForAssertion: import("bupkis/types").AssertionFunctionSync, "to have listener for", z.ZodUnion], (emitter: EventEmitterLike, eventName: string | symbol) => true | { actual: number; expected: number; message: string; }, readonly [z.ZodCustom, import("bupkis/types").PhraseLiteralSlot<"to have listener for">, z.ZodUnion]>; /** * Asserts that an emitter has listeners for all specified events. * * @example * * ```ts * const emitter = new EventEmitter(); * emitter.on('data', () => {}); * emitter.on('end', () => {}); * expect(emitter, 'to have listeners for', ['data', 'end']); // passes * ``` */ export declare const hasListenersForAssertion: import("bupkis/types").AssertionFunctionSync, "to have listeners for", z.ZodArray>], (emitter: EventEmitterLike, eventNames: (string | symbol)[]) => true | { actual: string[]; expected: string[]; message: string; }, readonly [z.ZodCustom, import("bupkis/types").PhraseLiteralSlot<"to have listeners for">, z.ZodArray>]>; /** * Asserts that an emitter has exactly the specified number of listeners for an * event. * * @example * * ```ts * const emitter = new EventEmitter(); * emitter.on('data', () => {}); * emitter.on('data', () => {}); * expect(emitter, 'to have listener count', 'data', 2); // passes * ``` */ export declare const hasListenerCountAssertion: import("bupkis/types").AssertionFunctionSync, "to have listener count", z.ZodUnion, z.ZodInt], (emitter: EventEmitterLike, eventName: string | symbol, expected: number) => true | { actual: number; expected: number; message: string; }, readonly [z.ZodCustom, import("bupkis/types").PhraseLiteralSlot<"to have listener count">, z.ZodUnion, z.ZodInt]>; /** * Asserts that an emitter has at least one listener registered. * * Use `'not to have listeners'` to assert that an emitter has no listeners. * * @example * * ```ts * const emitter = new EventEmitter(); * emitter.on('data', () => {}); * expect(emitter, 'to have listeners'); // passes * * const fresh = new EventEmitter(); * expect(fresh, 'not to have listeners'); // passes (negation) * ``` */ export declare const hasListenersAssertion: import("bupkis/types").AssertionFunctionSync, "to have listeners"], (emitter: EventEmitterLike) => true | { message: string; actual?: undefined; expected?: undefined; } | { actual: number; expected: number; message: string; }, readonly [z.ZodCustom, import("bupkis/types").PhraseLiteralSlot<"to have listeners">]>; /** * Asserts that an emitter's maxListeners is set to the specified value. * * @example * * ```ts * const emitter = new EventEmitter(); * emitter.setMaxListeners(20); * expect(emitter, 'to have max listeners', 20); // passes * ``` */ export declare const hasMaxListenersAssertion: import("bupkis/types").AssertionFunctionSync, "to have max listeners", z.ZodInt], (emitter: EventEmitterLike, expected: number) => true | { message: string; actual?: undefined; expected?: undefined; } | { actual: number; expected: number; message: string; }, readonly [z.ZodCustom, import("bupkis/types").PhraseLiteralSlot<"to have max listeners">, z.ZodInt]>; /** * Asserts that a trigger causes an emitter to emit the specified event with * timeout options. * * @example * * ```ts * const emitter = new EventEmitter(); * await expectAsync( * () => emitter.emit('ready'), * 'to emit from', * emitter, * 'ready', * { within: 100 }, * ); // passes or fails based on timing * ``` */ export declare const toEmitFromWithOptionsAssertion: import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to emit from", z.ZodCustom, z.ZodUnion, z.ZodType>], (trigger: Trigger, emitter: EventEmitterLike, eventName: string | symbol, options: TimeoutOptions) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to emit from">, z.ZodCustom, z.ZodUnion, z.ZodType>]>; /** * Asserts that a trigger causes an emitter to emit the specified event with * specific arguments. * * @example * * ```ts * const emitter = new EventEmitter(); * await expectAsync( * () => emitter.emit('data', 'hello', 42), * 'to emit from', * emitter, * 'data', * 'with args', * ['hello', 42], * ); // passes * ``` */ export declare const toEmitWithArgsFromAssertion: import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to emit from", z.ZodCustom, z.ZodUnion, "with args", z.ZodArray], (trigger: Trigger, emitter: EventEmitterLike, eventName: string | symbol, expectedArgs: unknown[]) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to emit from">, z.ZodCustom, z.ZodUnion, import("bupkis/types").PhraseLiteralSlot<"with args">, z.ZodArray]>; /** * Asserts that a trigger causes an emitter to emit the specified event with * specific arguments and timeout options. */ export declare const toEmitWithArgsFromWithOptionsAssertion: import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to emit from", z.ZodCustom, z.ZodUnion, "with args", z.ZodArray, z.ZodType>], (trigger: Trigger, emitter: EventEmitterLike, eventName: string | symbol, expectedArgs: unknown[], options: TimeoutOptions) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to emit from">, z.ZodCustom, z.ZodUnion, import("bupkis/types").PhraseLiteralSlot<"with args">, z.ZodArray, z.ZodType>]>; /** * Asserts that a trigger causes an emitter to emit the 'error' event with * timeout options. */ export declare const toEmitErrorFromWithOptionsAssertion: import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to emit error from", z.ZodCustom, z.ZodType>], (trigger: Trigger, emitter: EventEmitterLike, options: TimeoutOptions) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to emit error from">, z.ZodCustom, z.ZodType>]>; /** * Asserts that a trigger causes an emitter to emit events in the specified * order with timeout options. */ export declare const toEmitEventsFromWithOptionsAssertion: import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to emit events from", z.ZodCustom, z.ZodArray>, z.ZodType>], (trigger: Trigger, emitter: EventEmitterLike, expectedEvents: (string | symbol)[], options: TimeoutOptions) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to emit events from">, z.ZodCustom, z.ZodArray>, z.ZodType>]>; /** * Asserts that a trigger causes an EventTarget to dispatch the specified event * with timeout options. */ export declare const toDispatchFromWithOptionsAssertion: import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to dispatch from", z.ZodCustom, z.ZodString, z.ZodType>], (trigger: Trigger, target: EventTarget, eventType: string, options: TimeoutOptions) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to dispatch from">, z.ZodCustom, z.ZodString, z.ZodType>]>; /** * Asserts that a trigger causes an EventTarget to dispatch a CustomEvent with * specific detail. * * @example * * ```ts * const target = new EventTarget(); * await expectAsync( * () => * target.dispatchEvent( * new CustomEvent('custom', { detail: { foo: 'bar' } }), * ), * 'to dispatch from', * target, * 'custom', * 'with detail', * { foo: 'bar' }, * ); // passes * ``` */ export declare const toDispatchWithDetailFromAssertion: import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to dispatch from", z.ZodCustom, z.ZodString, "with detail", z.ZodUnknown], (trigger: Trigger, target: EventTarget, eventType: string, expectedDetail: unknown) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to dispatch from">, z.ZodCustom, z.ZodString, import("bupkis/types").PhraseLiteralSlot<"with detail">, z.ZodUnknown]>; /** * Asserts that a trigger causes an EventTarget to dispatch a CustomEvent with * specific detail and timeout options. */ export declare const toDispatchWithDetailFromWithOptionsAssertion: import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to dispatch from", z.ZodCustom, z.ZodString, "with detail", z.ZodUnknown, z.ZodType>], (trigger: Trigger, target: EventTarget, eventType: string, expectedDetail: unknown, options: TimeoutOptions) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to dispatch from">, z.ZodCustom, z.ZodString, import("bupkis/types").PhraseLiteralSlot<"with detail">, z.ZodUnknown, z.ZodType>]>; /** * All event assertions for use with `expect.use()`. */ export declare const eventAssertions: readonly [import("bupkis/types").AssertionFunctionSync, "to have listener for", z.ZodUnion], (emitter: EventEmitterLike, eventName: string | symbol) => true | { actual: number; expected: number; message: string; }, readonly [z.ZodCustom, import("bupkis/types").PhraseLiteralSlot<"to have listener for">, z.ZodUnion]>, import("bupkis/types").AssertionFunctionSync, "to have listeners for", z.ZodArray>], (emitter: EventEmitterLike, eventNames: (string | symbol)[]) => true | { actual: string[]; expected: string[]; message: string; }, readonly [z.ZodCustom, import("bupkis/types").PhraseLiteralSlot<"to have listeners for">, z.ZodArray>]>, import("bupkis/types").AssertionFunctionSync, "to have listener count", z.ZodUnion, z.ZodInt], (emitter: EventEmitterLike, eventName: string | symbol, expected: number) => true | { actual: number; expected: number; message: string; }, readonly [z.ZodCustom, import("bupkis/types").PhraseLiteralSlot<"to have listener count">, z.ZodUnion, z.ZodInt]>, import("bupkis/types").AssertionFunctionSync, "to have listeners"], (emitter: EventEmitterLike) => true | { message: string; actual?: undefined; expected?: undefined; } | { actual: number; expected: number; message: string; }, readonly [z.ZodCustom, import("bupkis/types").PhraseLiteralSlot<"to have listeners">]>, import("bupkis/types").AssertionFunctionSync, "to have max listeners", z.ZodInt], (emitter: EventEmitterLike, expected: number) => true | { message: string; actual?: undefined; expected?: undefined; } | { actual: number; expected: number; message: string; }, readonly [z.ZodCustom, import("bupkis/types").PhraseLiteralSlot<"to have max listeners">, z.ZodInt]>, import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to emit from", z.ZodCustom, z.ZodUnion], (trigger: Trigger, emitter: EventEmitterLike, eventName: string | symbol) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to emit from">, z.ZodCustom, z.ZodUnion]>, import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to emit from", z.ZodCustom, z.ZodUnion, z.ZodType>], (trigger: Trigger, emitter: EventEmitterLike, eventName: string | symbol, options: TimeoutOptions) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to emit from">, z.ZodCustom, z.ZodUnion, z.ZodType>]>, import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to emit from", z.ZodCustom, z.ZodUnion, "with args", z.ZodArray], (trigger: Trigger, emitter: EventEmitterLike, eventName: string | symbol, expectedArgs: unknown[]) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to emit from">, z.ZodCustom, z.ZodUnion, import("bupkis/types").PhraseLiteralSlot<"with args">, z.ZodArray]>, import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to emit from", z.ZodCustom, z.ZodUnion, "with args", z.ZodArray, z.ZodType>], (trigger: Trigger, emitter: EventEmitterLike, eventName: string | symbol, expectedArgs: unknown[], options: TimeoutOptions) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to emit from">, z.ZodCustom, z.ZodUnion, import("bupkis/types").PhraseLiteralSlot<"with args">, z.ZodArray, z.ZodType>]>, import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to emit error from", z.ZodCustom], (trigger: Trigger, emitter: EventEmitterLike) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to emit error from">, z.ZodCustom]>, import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to emit error from", z.ZodCustom, z.ZodType>], (trigger: Trigger, emitter: EventEmitterLike, options: TimeoutOptions) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to emit error from">, z.ZodCustom, z.ZodType>]>, import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to emit events from", z.ZodCustom, z.ZodArray>], (trigger: Trigger, emitter: EventEmitterLike, expectedEvents: (string | symbol)[]) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to emit events from">, z.ZodCustom, z.ZodArray>]>, import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to emit events from", z.ZodCustom, z.ZodArray>, z.ZodType>], (trigger: Trigger, emitter: EventEmitterLike, expectedEvents: (string | symbol)[], options: TimeoutOptions) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to emit events from">, z.ZodCustom, z.ZodArray>, z.ZodType>]>, import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to dispatch from", z.ZodCustom, z.ZodString], (trigger: Trigger, target: EventTarget, eventType: string) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to dispatch from">, z.ZodCustom, z.ZodString]>, import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to dispatch from", z.ZodCustom, z.ZodString, z.ZodType>], (trigger: Trigger, target: EventTarget, eventType: string, options: TimeoutOptions) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to dispatch from">, z.ZodCustom, z.ZodString, z.ZodType>]>, import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to dispatch from", z.ZodCustom, z.ZodString, "with detail", z.ZodUnknown], (trigger: Trigger, target: EventTarget, eventType: string, expectedDetail: unknown) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to dispatch from">, z.ZodCustom, z.ZodString, import("bupkis/types").PhraseLiteralSlot<"with detail">, z.ZodUnknown]>, import("bupkis/types").AssertionFunctionAsync, z.ZodCustom, Promise>]>, "to dispatch from", z.ZodCustom, z.ZodString, "with detail", z.ZodUnknown, z.ZodType>], (trigger: Trigger, target: EventTarget, eventType: string, expectedDetail: unknown, options: TimeoutOptions) => Promise, readonly [z.ZodUnion, z.ZodCustom, Promise>]>, import("bupkis/types").PhraseLiteralSlot<"to dispatch from">, z.ZodCustom, z.ZodString, import("bupkis/types").PhraseLiteralSlot<"with detail">, z.ZodUnknown, z.ZodType>]>]; //# sourceMappingURL=assertions.d.ts.map