/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import { type ITelemetryBaseEvent, type ITelemetryBaseLogger, LogLevel } from "@fluidframework/core-interfaces"; import { createChildLogger } from "./logger.js"; import type { ITelemetryEventExt, TelemetryLoggerExt } from "./telemetryTypes.js"; /** * Mock {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} implementation. * * Records events sent to it, and then can walk back over those events, searching for a set of expected events to * match against the logged events. * * @internal */ export declare class MockLogger implements ITelemetryBaseLogger { /** * Gets an immutable copy of the events logged thus far. */ get events(): readonly ITelemetryBaseEvent[]; private _events; /** * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.minLogLevel} */ readonly minLogLevel: LogLevel; constructor(minLogLevel?: LogLevel); /** * Clears the events logged thus far. */ clear(): void; toTelemetryLogger(): ReturnType; /** * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.send} */ send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void; /** * Search events logged since the last time matchEvents was called, looking for the given expected * events in order. * @param expectedEvents - events in order that are expected to appear in the recorded log. * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined. * These event objects may be subsets of the logged events. * Note: category is omitted from the type because it's usually uninteresting and tedious to type. * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check. * Default: true. */ matchEvents(expectedEvents: Omit[], inlineDetailsProp?: boolean, clearEventsAfterCheck?: boolean): boolean; /** * Asserts {@link MockLogger.matchEvents} is `true` for the given events. * @param expectedEvents - The events expected to appear. * @param message - Optional error message to include in the thrown error, if the condition is not satisfied. * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined. * These event objects may be subsets of the logged events. * Note: category is omitted from the type because it's usually uninteresting and tedious to type. * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check. * Default: true. * @throws An error containing the actual/expected event data if the condition is not satisfied. */ assertMatch(expectedEvents: Omit[], message?: string, inlineDetailsProp?: boolean, clearEventsAfterCheck?: boolean): void; /** * Search events logged since the last time matchEvents was called, looking for any of the given * expected events. * @param expectedEvents - events that are expected to appear in the recorded log. * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined. * These event objects may be subsets of the logged events. * Note: category is omitted from the type because it's usually uninteresting and tedious to type. * @returns if any of the expected events is found. */ matchAnyEvent(expectedEvents: Omit[], inlineDetailsProp?: boolean, clearEventsAfterCheck?: boolean): boolean; /** * Asserts {@link MockLogger.matchAnyEvent} is `true` for the given events. * @param expectedEvents - The events expected to appear. * @param message - Optional error message to include in the thrown error, if the condition is not satisfied. * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined. * These event objects may be subsets of the logged events. * Note: category is omitted from the type because it's usually uninteresting and tedious to type. * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check. * Default: true. * @throws An error containing the actual/expected event data if the condition is not satisfied. */ assertMatchAny(expectedEvents: Omit[], message?: string, inlineDetailsProp?: boolean, clearEventsAfterCheck?: boolean): void; /** * Search events logged since the last time matchEvents was called, looking only for the given expected * events in order. * @param expectedEvents - events in order that are expected to be the only events in the recorded log. * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined. * These event objects may be subsets of the logged events. * Note: category is omitted from the type because it's usually uninteresting and tedious to type. * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check. * Default: true. */ matchEventStrict(expectedEvents: Omit[], inlineDetailsProp?: boolean, clearEventsAfterCheck?: boolean): boolean; /** * Asserts {@link MockLogger.matchEvents} is `true` for the given events. * @param expectedEvents - The events expected to appear. * @param message - Optional error message to include in the thrown error, if the condition is not satisfied. * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined. * These event objects may be subsets of the logged events. * Note: category is omitted from the type because it's usually uninteresting and tedious to type. * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check. * Default: true. * @throws An error containing the actual/expected event data if the condition is not satisfied. */ assertMatchStrict(expectedEvents: Omit[], message?: string, inlineDetailsProp?: boolean, clearEventsAfterCheck?: boolean): void; /** * Asserts {@link MockLogger.matchAnyEvent} is `false` for the given events. * @param disallowedEvents - The events expected to not appear. * @param message - Optional error message to include in the thrown error, if the condition is not satisfied. * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined. * These event objects may be subsets of the logged events. * Note: category is omitted from the type because it's usually uninteresting and tedious to type. * @param clearEventsAfterCheck - Whether or not to clear the logger's {@link MockLogger.events} after performing the check. * Default: true. * @throws An error containing the actual/expected event data if the condition is not satisfied. */ assertMatchNone(disallowedEvents: Omit[], message?: string, inlineDetailsProp?: boolean, clearEventsAfterCheck?: boolean): void; private getMatchedEventsCount; /** * Ensure the expected event is a strict subset of the actual event */ private static eventsMatch; /** * Throws if any errors were logged */ assertNoErrors(message?: string, clearEventsAfterCheck?: boolean): void; } /** * Mock {@link TelemetryLoggerExt} implementation. * * @remarks Can be created via {@link createMockLoggerExt}. * * @internal */ export interface IMockLoggerExt extends TelemetryLoggerExt { /** * Gets the events that have been logged so far. */ events(): readonly ITelemetryEventExt[]; } /** * Creates an {@link IMockLoggerExt}. * * @internal */ export declare function createMockLoggerExt(minLogLevel?: LogLevel): IMockLoggerExt; //# sourceMappingURL=mockLogger.d.ts.map