/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Callable } from "./Function.js"; /** * Mock fetch response configuration */ export interface FetchMockResponse { url: string | RegExp; responseData: any; options?: FetchMockResponseOptions; } /** * Options for adding a mock response */ export interface FetchMockResponseOptions { status?: number; binary?: boolean; } /** * Call log entry */ export interface FetchCallLogEntry { url: string; options: any; } /** * Mock implementation of the global fetch API for testing purposes. * * This class allows you to intercept and mock fetch calls made during tests, * making it possible to test code that makes HTTP requests without actually * hitting real endpoints. * * @example * ```typescript * const fetchMock = new MockFetch(); * fetchMock.addResponse("/api/data", { result: "success" }); * fetchMock.install(); * * // Your code that calls fetch("/api/data") will now receive the mocked response * * fetchMock.uninstall(); * ``` */ export declare class MockFetch extends Callable { private responses; private originalFetch; private callLog; private installed; constructor(); /** * Add a mock response for a specific URL pattern. * * @param urlPattern - String or RegExp to match against request URLs * @param responseData - Data to return (will be serialized to JSON or returned as binary) * @param options - Optional configuration for status code and binary responses */ addResponse(urlPattern: string | RegExp, responseData: any, options?: FetchMockResponseOptions): void; /** * Install this mock as the global fetch implementation. * Must be called before the code under test executes fetch calls. */ install(): void; /** * Restore the original fetch implementation and clear all mocks. */ uninstall(): void; /** * Get a log of all fetch calls that were made. * Useful for verifying that expected requests were made. * * @returns Array of call log entries with URL and options */ getCallLog(): FetchCallLogEntry[]; /** * Clear all registered mock responses. */ clearResponses(): void; /** * Clear the call log. */ clearCallLog(): void; /** * Clear both responses and call log. */ clear(): void; /** * Internal mock fetch implementation. */ private mockFetch; } //# sourceMappingURL=MockFetch.d.ts.map