first commit
Verify / test (push) Failing after 2m54s

This commit is contained in:
2026-11-05 17:31:17 +03:30
کامیت 56c5ee23d3
63فایلهای تغییر یافته به همراه2749 افزوده شده و 0 حذف شده
+19
مشاهده پرونده
@@ -0,0 +1,19 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { Camera } from './camera.js';
const close = (a,b) => assert.ok(Math.abs(a-b)<1e-8,`${a} != ${b}`);
test('fit preserves sheet aspect ratio without padding',()=> {
const c = new Camera({x:0,y:-760,width:1150,height:760},1920,1080);
close(c.scale,1080/760); close(c.y,1080);
const center = c.world(960,540); close(center.x,575); close(center.y,-380);
});
test('zoom retains exact world coordinate under cursor',()=> {
const c = new Camera({x:0,y:-760,width:1150,height:760},1000,800);
const p = c.world(121,534); c.zoom(3.2,121,534); const q = c.world(121,534);
close(p.x,q.x); close(p.y,q.y); c.pan(12,-8); const r=c.world(133,526); close(r.x,p.x); close(r.y,p.y);
});
test('zoom is bounded for hostile wheel deltas',()=> {
const c = new Camera({x:0,y:0,width:100,height:100},1000,800);
c.zoom(1e30,0,0); close(c.scale,c.fitScale*200);
c.zoom(1e-30,0,0); close(c.scale,c.fitScale*.05);
});