From cb6fd7568a8a4993cc835b7a2f96a206fd0f4991 Mon Sep 17 00:00:00 2001 From: Said Turksever Date: Sat, 31 Oct 2026 23:18:42 +0000 Subject: [PATCH] =?UTF-8?q?test(draw):=20pin=20the=20shoelace=20area=20in?= =?UTF-8?q?=20the=20km=C2=B2=20and=20ha=20rounding=20cases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/annotations/drawMode.test.mjs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/annotations/drawMode.test.mjs b/src/annotations/drawMode.test.mjs index 51e3b854e..8018b4527 100644 --- a/src/annotations/drawMode.test.mjs +++ b/src/annotations/drawMode.test.mjs @@ -369,6 +369,19 @@ test('an area that rounds up to the next unit reads in that unit', () => { assert.equal(formatMeasure(almostHectare), '1.0 ha'); assert.match(drawHint(almostHectare), /^1\.0 ha · /); assert.equal(formatMeasure(square(9999.4)), '9999 m²'); - assert.equal(formatMeasure(square(999_960)), '1.00 km²'); - assert.equal(formatMeasure(square(999_400)), '99.9 ha'); + // Pin the shoelace area too, so a geodesy change fails here and not as a unit. + const almostKm2 = square(999_960); + const nearKm2 = ringAreaM2(almostKm2.vertices); + assert.ok( + nearKm2 >= 999_500 && nearKm2 < 1e6, + `area should round to 100.0 ha, got ${nearKm2}`, + ); + assert.equal(formatMeasure(almostKm2), '1.00 km²'); + const under = square(999_400); + const underM2 = ringAreaM2(under.vertices); + assert.ok( + underM2 >= 998_500 && underM2 < 999_500, + `area should round to 99.9 ha, got ${underM2}`, + ); + assert.equal(formatMeasure(under), '99.9 ha'); });