From 17ce0a5e107e4747f5347731e8dd285ae7177a47 Mon Sep 17 00:00:00 2001 From: James Beard Date: Tue, 19 Nov 2024 16:19:12 +1100 Subject: [PATCH] Added a regression test for clone() bug that was probably fixed a while ago. --- packages/turf-clone/test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/turf-clone/test.ts b/packages/turf-clone/test.ts index 7e47d9ca04..4564e794d4 100644 --- a/packages/turf-clone/test.ts +++ b/packages/turf-clone/test.ts @@ -3,6 +3,7 @@ import { point, lineString, polygon, + feature, featureCollection, geometryCollection, } from "@turf/helpers"; @@ -319,3 +320,29 @@ test("turf-clone -- Feature with null geometry", (t) => { t.deepEqual(fc, cloned); t.end(); }); + +test("turf-clone -- Feature with property called 'length', issue #1621", (t) => { + const f = feature( + { type: "Point", coordinates: [0, 0] }, + { + processed: { + length: { + orig: 123.456, + opti: 100.0, + }, + }, + } + ); + + // Clone + const cloned = clone(f); + + t.deepEqual(f, cloned, "cloned feature should be deeply equal"); + t.equal( + cloned.properties.processed.length.orig, + 123.456, + "'orig' property should be preserved on 'processed.length' element" + ); + + t.end(); +});