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
JavaScript
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 };