From 9927d120505929364da96785412c1f262ded4db6 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 3 Oct 2026 06:22:19 +0000 Subject: [PATCH] chore(core): cover viewport minimum zoom branches Covers behavior-pan attribute removal and the minimum-scale zoom-out path, raising viewport.ts line coverage to 100% and branch coverage to 90%. No behavior change. Signed-off-by: Cursor Agent Co-authored-by: Cory Rylan --- projects/core/src/viewport/viewport.test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/projects/core/src/viewport/viewport.test.ts b/projects/core/src/viewport/viewport.test.ts index d52419112..3bf0e70ce 100644 --- a/projects/core/src/viewport/viewport.test.ts +++ b/projects/core/src/viewport/viewport.test.ts @@ -79,6 +79,10 @@ describe(Viewport.metadata.tag, () => { expect(element.hasAttribute('autofit')).toBe(true); expect(element.getAttribute('fit-inset')).toBe('24'); + element.removeAttribute('behavior-pan'); + await elementIsStable(element); + expect(element.behaviorPan).toBe(false); + element.x = Number.NaN; element.y = Number.POSITIVE_INFINITY; element.scale = 0; @@ -775,6 +779,23 @@ describe(Viewport.metadata.tag, () => { }); describe('animation integration', () => { + it('keeps the minimum scale for an animated zoom-out request', async () => { + element.behaviorZoom = true; + element.minScale = 0.3; + element.scale = 0.3; + await elementIsStable(element); + const animationFrame = vi.spyOn(globalThis, 'requestAnimationFrame'); + const zoom = vi.fn(); + element.addEventListener('zoom', zoom); + + element.dispatchEvent(new CommandEvent('command', { command: '--zoom-out' })); + + expect(zoom).toHaveBeenCalledOnce(); + expect((zoom.mock.calls[0]?.[0] as CustomEvent).detail.next.scale).toBe(0.3); + expect(animationFrame).not.toHaveBeenCalled(); + expect(element.scale).toBe(0.3); + }); + it('animates one keyboard zoom proposal and steps later keys from the pending destination', async () => { element.behaviorZoom = true; await elementIsStable(element);