2026-06-10 12:49:43 +08:00
|
|
|
// test/base.test.js
|
|
|
|
|
window.runTests = async function() {
|
2026-05-14 20:04:31 +08:00
|
|
|
console.log('Starting comprehensive Base.js tests...');
|
|
|
|
|
|
|
|
|
|
// 1. HTTP Test
|
|
|
|
|
console.log('Testing HTTP (local check)...');
|
2026-06-10 12:49:43 +08:00
|
|
|
if (typeof HTTP === 'undefined') throw new Error('Global HTTP not found');
|
2026-05-27 23:02:25 +08:00
|
|
|
|
2026-06-10 12:49:43 +08:00
|
|
|
// 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');
|
2026-05-29 22:45:56 +08:00
|
|
|
|
2026-06-10 12:49:43 +08:00
|
|
|
// 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');
|
2026-05-27 23:02:25 +08:00
|
|
|
|
2026-06-10 12:49:43 +08:00
|
|
|
// 4. State Integration
|
|
|
|
|
console.log('Testing State integration...');
|
|
|
|
|
if (typeof State === 'undefined') throw new Error('Global State not found');
|
2026-05-27 23:02:25 +08:00
|
|
|
|
2026-06-10 12:49:43 +08:00
|
|
|
// 5. VirtualScroll logic
|
|
|
|
|
console.log('Testing VirtualScroll...');
|
|
|
|
|
if (typeof VirtualScroll === 'undefined') throw new Error('Global VirtualScroll not found');
|
2026-05-14 20:04:31 +08:00
|
|
|
|
2026-06-10 12:49:43 +08:00
|
|
|
// Benchmark placeholders (visual verification required via UI)
|
2026-05-14 20:04:31 +08:00
|
|
|
const measure = async (id, name) => {
|
2026-06-10 12:49:43 +08:00
|
|
|
const list = document.getElementById(id);
|
|
|
|
|
if (!list) return;
|
2026-05-14 20:04:31 +08:00
|
|
|
const start = performance.now();
|
2026-06-10 12:49:43 +08:00
|
|
|
switchTab(id);
|
|
|
|
|
await new Promise(r => setTimeout(r, 100));
|
|
|
|
|
console.log(`BENCHMARK [${name}]: ${performance.now() - start}ms, Items: ${list.state?.renderedList?.length}`);
|
2026-05-14 20:04:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await measure('ll', 'FastList');
|
|
|
|
|
await measure('gl', 'FastGroupedList');
|
|
|
|
|
await measure('tt', 'FastTree');
|
|
|
|
|
await measure('ct', 'CollapseTree');
|
|
|
|
|
|
|
|
|
|
console.log('All Base.js unit tests completed.');
|
|
|
|
|
}
|