/** * Photon Testing Utilities * * Helpers for writing tests in photons * * Usage in photon: * import { mock, expect } from '@portel/photon/testing'; */ /** * Mock a method on an object, returns a restore function * * @example * ```typescript * async testWithMock() { * const restore = mock(this, 'fetchData', async () => ({ data: 'mocked' })); * const result = await this.process(); * restore(); * return { passed: result.data === 'mocked' }; * } * ``` */ export declare function mock(obj: T, method: K, implementation: T[K]): () => void; /** * Create a mock function that tracks calls * * @example * ```typescript * const mockFn = fn(() => 'mocked'); * mockFn('arg1', 'arg2'); * console.log(mockFn.calls); // [['arg1', 'arg2']] * console.log(mockFn.callCount); // 1 * ``` */ export declare function fn any>(implementation?: T): T & { calls: Parameters[]; callCount: number; reset: () => void; }; /** * Simple assertion helpers */ export declare const expect: { /** * Assert two values are equal (===) */ equal(actual: T, expected: T, message?: string): void; /** * Assert two values are deeply equal */ deepEqual(actual: T, expected: T, message?: string): void; /** * Assert value is truthy */ truthy(value: any, message?: string): void; /** * Assert value is falsy */ falsy(value: any, message?: string): void; /** * Assert function throws */ throws(fn: () => unknown, message?: string): Promise; /** * Assert array contains value */ contains(array: T[], value: T, message?: string): void; /** * Assert value matches regex */ matches(value: string, pattern: RegExp, message?: string): void; }; /** * Skip a test with a reason * * @example * ```typescript * async testRequiresRedis() { * if (!process.env.REDIS_URL) { * return skip('REDIS_URL not configured'); * } * // actual test... * } * ``` */ export declare function skip(reason: string): { skipped: true; reason: string; }; /** * Test context for auto-cleanup of mocks */ export declare class TestContext { private restoreFns; /** * Mock a method with auto-restore on cleanup */ mock(obj: T, method: K, implementation: T[K]): void; /** * Restore all mocks */ cleanup(): void; } //# sourceMappingURL=testing.d.ts.map