UNPKG

bigbasealpha

Version:

Professional Grade Custom Database System - A sophisticated, dependency-free database with encryption, caching, indexing, and web dashboard

126 lines (93 loc) โ€ข 3.4 kB
import BigBaseAlpha from '../src/alpha.js'; /** * Test file for Terminal UI Framework and Performance Analytics */ console.log('๐Ÿงช Testing BigBaseAlpha v1.3.0 Features\n'); async function testTerminalUI() { console.log('๐Ÿ“Š Testing Terminal UI Framework...'.cyan); const alpha = new BigBaseAlpha({ path: './test_ui_data', encryption: false, ui: { colors: true, animation: true } }); try { await alpha.init(); // Test chart creation const chart = alpha.createChart({ type: 'bar', values: [ { label: 'Test1', value: 10 }, { label: 'Test2', value: 20 } ] }, { title: 'Test Chart', color: 'green' }); console.log('โœ… Chart creation: PASSED'); // Test table creation const table = alpha.createTable([ { ID: 1, Name: 'Test', Status: 'OK' } ], { title: 'Test Table' }); console.log('โœ… Table creation: PASSED'); alpha.close(); } catch (error) { console.error('โŒ Terminal UI test failed:', error.message); return false; } return true; } async function testPerformanceAnalytics() { console.log('\n๐Ÿ” Testing Performance Analytics...'.cyan); const alpha = new BigBaseAlpha({ path: './test_perf_data', encryption: false, performance: { enableProfiling: true } }); try { await alpha.init(); // Test profiling alpha.startProfile('test_operation'); // Simulate some work await new Promise(resolve => setTimeout(resolve, 100)); const result = alpha.endProfile('test_operation'); if (result.duration > 0) { console.log('โœ… Profiling: PASSED'); } else { throw new Error('Invalid profiling result'); } // Test system metrics const metrics = alpha.getSystemMetrics(); if (metrics.cpu && metrics.memory) { console.log('โœ… System metrics: PASSED'); } else { throw new Error('Invalid system metrics'); } alpha.close(); } catch (error) { console.error('โŒ Performance Analytics test failed:', error.message); return false; } return true; } async function runTests() { const results = []; try { results.push(await testTerminalUI()); results.push(await testPerformanceAnalytics()); const passed = results.filter(r => r).length; const total = results.length; console.log(`\n๐Ÿ“Š Test Results: ${passed}/${total} passed`.green); if (passed === total) { console.log('๐ŸŽ‰ All tests passed!'.rainbow); process.exit(0); } else { console.log('โŒ Some tests failed!'.red); process.exit(1); } } catch (error) { console.error('๐Ÿ’ฅ Test suite error:', error); process.exit(1); } } // Run tests if this file is executed directly if (import.meta.url === `file://${process.argv[1]}`) { runTests(); } export { testTerminalUI, testPerformanceAnalytics };