mirror of
https://github.com/fancive/obsidian-parallel-reader.git
synced 2026-07-22 06:53:43 +00:00
Replaces the monolithic modules.test.js (983 lines) with focused per-module test files sharing a common test-setup.js. Each file is under 225 lines. All existing test assertions preserved. New files: test-setup.js, anchor.test.js, schema.test.js, cache.test.js, cards-nav.test.js, markdown.test.js, vault-batch.test.js, i18n.test.js, scroll.test.js, settings.test.js, providers.test.js, streaming.test.js, cli.test.js Change-Id: I37a3342a1588807277e679e6535cde361e650565
17 lines
818 B
JavaScript
17 lines
818 B
JavaScript
const { assert, t } = require('./test-setup');
|
|
|
|
assert.strictEqual(t.visibleTopProbeY({ top: 0, height: 0 }), 0, 'zero rect');
|
|
assert.strictEqual(t.visibleTopProbeY(null), 0, 'null rect');
|
|
assert.strictEqual(t.visibleTopProbeY({ top: 50, height: 500 }), 100, 'standard rect: min(80, 500*0.1)=50, 50+50=100');
|
|
assert.strictEqual(t.visibleTopProbeY({ top: 100, height: 300 }), 130, 'small rect offset 10%');
|
|
assert.strictEqual(t.visibleTopProbeY({ top: 100, height: 1200 }), 180, 'large rect capped at 80');
|
|
|
|
const frames = [];
|
|
const throttled = t.createRafThrottledHandler(() => {}, cb => { frames.push(cb); return frames.length; });
|
|
throttled();
|
|
assert.strictEqual(frames.length, 1);
|
|
throttled.cancel();
|
|
throttled();
|
|
assert.strictEqual(frames.length, 2, 'new frame after cancel');
|
|
|
|
console.log('scroll tests passed');
|