Skip to content

Commit 17ce0a5

Browse files
committed
Added a regression test for clone() bug that was probably fixed a while ago.
1 parent 5d1e0ec commit 17ce0a5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

packages/turf-clone/test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
point,
44
lineString,
55
polygon,
6+
feature,
67
featureCollection,
78
geometryCollection,
89
} from "@turf/helpers";
@@ -319,3 +320,29 @@ test("turf-clone -- Feature with null geometry", (t) => {
319320
t.deepEqual(fc, cloned);
320321
t.end();
321322
});
323+
324+
test("turf-clone -- Feature with property called 'length', issue #1621", (t) => {
325+
const f = feature(
326+
{ type: "Point", coordinates: [0, 0] },
327+
{
328+
processed: {
329+
length: {
330+
orig: 123.456,
331+
opti: 100.0,
332+
},
333+
},
334+
}
335+
);
336+
337+
// Clone
338+
const cloned = clone(f);
339+
340+
t.deepEqual(f, cloned, "cloned feature should be deeply equal");
341+
t.equal(
342+
cloned.properties.processed.length.orig,
343+
123.456,
344+
"'orig' property should be preserved on 'processed.length' element"
345+
);
346+
347+
t.end();
348+
});

0 commit comments

Comments
 (0)