UNPKG

tradingview-screener-ts

Version:

TypeScript port of TradingView Screener with 100% Python parity - Based on the original Python library by shner-elmo (https://github.com/shner-elmo/TradingView-Screener)

214 lines 5.95 kB
/** * Advanced testing utilities and mock data * * This module provides comprehensive testing utilities, mock data generators, * and test helpers to achieve 100% test coverage and quality assurance. */ import type { ScreenerDataResult, FilterOperationDict, QueryDict } from './types/models'; /** * Mock data generator for testing */ export declare class MockDataGenerator { /** * Generate mock stock data */ static generateMockStockData(count?: number): ScreenerDataResult; /** * Generate mock crypto data */ static generateMockCryptoData(count?: number): ScreenerDataResult; /** * Generate mock India stock data */ static generateMockIndiaStockData(count?: number): ScreenerDataResult; /** * Generate mock filter operation */ static generateMockFilter(): FilterOperationDict; /** * Generate mock query */ static generateMockQuery(): QueryDict; } /** * Test utilities for assertions and validations */ export declare class TestUtils { /** * Assert that data matches expected structure */ static assertScreenerDataStructure(data: any): asserts data is ScreenerDataResult; /** * Assert that filter operation is valid */ static assertValidFilter(filter: any): asserts filter is FilterOperationDict; /** * Measure execution time */ static measureExecutionTime<T>(fn: () => Promise<T>): Promise<{ result: T; executionTime: number; }>; /** * Create performance benchmark */ static benchmark<T>(name: string, fn: () => Promise<T>, iterations?: number): Promise<{ name: string; iterations: number; averageTime: number; minTime: number; maxTime: number; totalTime: number; }>; /** * Validate API response structure */ static validateApiResponse(response: any): { isValid: boolean; errors: string[]; warnings: string[]; }; /** * Generate test report */ static generateTestReport(results: any[]): { totalTests: number; passed: number; failed: number; skipped: number; coverage: number; duration: number; summary: string; }; } /** * Mock HTTP client for testing */ export declare class MockHttpClient { private responses; private requestLog; /** * Set mock response for URL */ setMockResponse(url: string, response: any): void; /** * Mock HTTP request */ request(url: string, config?: any): Promise<any>; /** * Get request log */ getRequestLog(): Array<{ url: string; config: any; timestamp: number; }>; /** * Clear request log */ clearLog(): void; /** * Reset all mocks */ reset(): void; } /** * Test data fixtures */ export declare const TestFixtures: { /** * Sample stock data */ readonly stockData: ScreenerDataResult; /** * Sample crypto data */ readonly cryptoData: ScreenerDataResult; /** * Sample India stock data */ readonly indiaStockData: ScreenerDataResult; /** * Sample error responses */ readonly errorResponses: { readonly networkError: Error; readonly timeoutError: Error; readonly authError: Error; readonly rateLimitError: Error; readonly serverError: Error; }; /** * Sample queries */ readonly sampleQueries: { readonly basicStock: { readonly markets: readonly ["america"]; readonly columns: readonly ["name", "close", "volume"]; readonly range: readonly [0, 50]; }; readonly indiaStock: { readonly markets: readonly ["india"]; readonly columns: readonly ["name", "close", "volume", "market_cap_basic"]; readonly range: readonly [0, 30]; }; readonly crypto: { readonly markets: readonly ["crypto"]; readonly columns: readonly ["name", "close", "volume", "market_cap_calc"]; readonly range: readonly [0, 20]; }; }; }; /** * Export testing utilities */ export declare const Testing: { readonly MockDataGenerator: typeof MockDataGenerator; readonly TestUtils: typeof TestUtils; readonly MockHttpClient: typeof MockHttpClient; readonly TestFixtures: { /** * Sample stock data */ readonly stockData: ScreenerDataResult; /** * Sample crypto data */ readonly cryptoData: ScreenerDataResult; /** * Sample India stock data */ readonly indiaStockData: ScreenerDataResult; /** * Sample error responses */ readonly errorResponses: { readonly networkError: Error; readonly timeoutError: Error; readonly authError: Error; readonly rateLimitError: Error; readonly serverError: Error; }; /** * Sample queries */ readonly sampleQueries: { readonly basicStock: { readonly markets: readonly ["america"]; readonly columns: readonly ["name", "close", "volume"]; readonly range: readonly [0, 50]; }; readonly indiaStock: { readonly markets: readonly ["india"]; readonly columns: readonly ["name", "close", "volume", "market_cap_basic"]; readonly range: readonly [0, 30]; }; readonly crypto: { readonly markets: readonly ["crypto"]; readonly columns: readonly ["name", "close", "volume", "market_cap_calc"]; readonly range: readonly [0, 20]; }; }; }; }; //# sourceMappingURL=testing.d.ts.map