base/test/base.test.js

45 lines
1.8 KiB
JavaScript
Raw Permalink Normal View History

// test/base.test.js
window.runTests = async function() {
console.log('Starting comprehensive Base.js tests...');
// 1. HTTP Test
console.log('Testing HTTP (local check)...');
if (typeof HTTP === 'undefined') throw new Error('Global HTTP not found');
// 2. UI Test
console.log('Testing UI...');
if (typeof UI === 'undefined') throw new Error('Global UI not found');
if (typeof UI.alert !== 'function') throw new Error('UI.alert not found');
// 3. Component Check
console.log('Testing Components...');
if (!Component.exists('Modal')) throw new Error('Modal component not registered');
if (!Component.exists('AutoForm')) throw new Error('AutoForm component not registered');
if (!Component.exists('FastList')) throw new Error('FastList component not registered');
// 4. State Integration
console.log('Testing State integration...');
if (typeof State === 'undefined') throw new Error('Global State not found');
// 5. VirtualScroll logic
console.log('Testing VirtualScroll...');
if (typeof VirtualScroll === 'undefined') throw new Error('Global VirtualScroll not found');
// Benchmark placeholders (visual verification required via UI)
const measure = async (id, name) => {
const list = document.getElementById(id);
if (!list) return;
const start = performance.now();
switchTab(id);
await new Promise(r => setTimeout(r, 100));
console.log(`BENCHMARK [${name}]: ${performance.now() - start}ms, Items: ${list.state?.renderedList?.length}`);
};
await measure('ll', 'FastList');
await measure('gl', 'FastGroupedList');
await measure('tt', 'FastTree');
await measure('ct', 'CollapseTree');
console.log('All Base.js unit tests completed.');
}