/** * Assertion helpers for O-Network testing * * Provides type-safe, expressive assertions for common test scenarios */ import { oResponse } from '@olane/o-core'; /** * Assert that a tool response indicates success * * @param response - Tool method response (oResponse) * @param message - Optional custom error message * @throws Error if response is not successful * * @example * ```typescript * const response = await tool.use(address, { method: 'test', params: {} }); * assertSuccess(response); * ``` */ export declare function assertSuccess(response: oResponse, message?: string): asserts response is oResponse & { result: { success: true; }; }; /** * Assert that a tool response indicates failure * * @param response - Tool method response (oResponse) * @param expectedError - Optional substring to match in error message * @throws Error if response is successful or error doesn't match * * @example * ```typescript * const response = await tool.use(address, { method: 'test', params: {} }); * assertError(response, 'required'); * ``` */ export declare function assertError(response: oResponse, expectedError?: string): asserts response is oResponse & { result: { success: false; }; }; /** * Assert that a node is in running state * * @param node - Node instance * @param message - Optional custom error message * @throws Error if node is not running * * @example * ```typescript * assertRunning(tool); * ``` */ export declare function assertRunning(node: any, message?: string): void; /** * Assert that a node is in stopped state * * @param node - Node instance * @param message - Optional custom error message * @throws Error if node is not stopped * * @example * ```typescript * await tool.stop(); * assertStopped(tool); * ``` */ export declare function assertStopped(node: any, message?: string): void; /** * Assert that response has data * * @param response - Tool method response (oResponse) * @param message - Optional custom error message * @throws Error if response doesn't have data * * @example * ```typescript * const response = await tool.use(address, { method: 'get_data', params: {} }); * assertHasData(response); * const data = response.result.data; * ``` */ export declare function assertHasData(response: oResponse, message?: string): asserts response is oResponse & { result: { data: any; }; }; /** * Assert that a value is defined (not null or undefined) * * @param value - Value to check * @param name - Name of the value for error message * @throws Error if value is null or undefined * * @example * ```typescript * assertDefined(user, 'user'); * // Now TypeScript knows user is not null/undefined * ``` */ export declare function assertDefined(value: T, name?: string): asserts value is NonNullable; /** * Assert that an array has expected length * * @param array - Array to check * @param expectedLength - Expected length * @param message - Optional custom error message * @throws Error if length doesn't match * * @example * ```typescript * assertArrayLength(items, 5); * ``` */ export declare function assertArrayLength(array: any[], expectedLength: number, message?: string): void; /** * Assert that an object has a property * * @param obj - Object to check * @param property - Property name * @param message - Optional custom error message * @throws Error if property doesn't exist * * @example * ```typescript * assertHasProperty(response.result.data, 'userId'); * ``` */ export declare function assertHasProperty(obj: T, property: K, message?: string): asserts obj is T & Record; /** * Assert that a value matches one of the expected values * * @param value - Value to check * @param expectedValues - Array of expected values * @param message - Optional custom error message * @throws Error if value doesn't match any expected value * * @example * ```typescript * assertOneOf(status, ['pending', 'active', 'completed']); * ``` */ export declare function assertOneOf(value: T, expectedValues: T[], message?: string): void; /** * Create a custom assertion * * @param condition - Condition to check * @param message - Error message if condition is false * @throws Error if condition is false * * @example * ```typescript * assert(user.age >= 18, 'User must be 18 or older'); * ``` */ export declare function assert(condition: boolean, message: string): asserts condition; //# sourceMappingURL=assertions.d.ts.map