diff --git a/src/cockpitMath.test.mjs b/src/cockpitMath.test.mjs index dd4d55a689..3f8d396211 100644 --- a/src/cockpitMath.test.mjs +++ b/src/cockpitMath.test.mjs @@ -31,6 +31,7 @@ import { speedRulerStep, speedRulerTicks, } from './cockpitMath.js'; +import { bandBesideMidpointObstacles } from './ui/panelRailGeometry.js'; test('cockpit presentation updates are throttled independently of camera frames', () => { assert.equal(cockpitUiUpdateDue(1000, 0, 100), true); @@ -390,12 +391,22 @@ test('HUD rail layout counts obstacles beside those across the midpoint', () => // Neighbours exactly two gaps away leave no room between: one block, 100 // to 400, and a tie (50px a side) goes above. assert.deepEqual(band([[100, 180], [200, 300], [320, 400]]), [40, 90]); - // A neighbour exactly two gaps below joins it too: 150 to 300, 110px + // A neighbour exactly two gaps below joins it too: 150 to 300, 100px // above against 150 below. assert.deepEqual(band([[150, 250], [270, 300]]), [310, 460]); // A side under 8% of the window (38.4px) is no room: 30px above, none // below, so the band stays as it is. assert.deepEqual(band([[80, 455]]), [40, 460]); + // Exactly the minimum is enough. + const exact = bandBesideMidpointObstacles({ + midpoint: 240, + top: 40, + bottom: 460, + obstacles: [{ top: 90, bottom: 465 }], + gap: 10, + minimum: 40, + }); + assert.deepEqual([exact?.top, exact?.bottom], [40, 80]); }); test('HUD rail layout keeps a band beside a midpoint obstacle inside its own edges', () => {