Skip to content

Commit 2c93709

Browse files
committed
removes reserved properties of Entities
1 parent 031d0d1 commit 2c93709

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

packages/web-forms/src/components/common/map/createFeatureCollectionAndProps.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const RESERVED_MAP_PROPERTIES = [
1010
'stroke',
1111
'stroke-width',
1212
'fill',
13+
'__version',
14+
'__trunkVersion',
15+
'__branchId',
1316
];
1417

1518
type Coordinates = [longitude: number, latitude: number];

packages/web-forms/tests/components/common/map/createFeatureCollectionAndProps.test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,56 @@ describe('createFeatureCollectionAndProps', () => {
264264
);
265265
});
266266

267+
it('removes reserved properties of Entities in orderedExtraPropsMap', () => {
268+
const odkFeatures: SelectItem[] = [
269+
createSelectItem('point1', 'Point 1', '40.7128 -74.0060 100 5', [
270+
['__version', 'v34.29.7'],
271+
['clinic-name', 'New Hope Clinic'],
272+
['__trunkVersion', 'v1.1.1'],
273+
['__clinic-id', '123456'],
274+
['__branchId', 'id-abc'],
275+
['another-prop', 'value2'],
276+
]),
277+
];
278+
279+
const { featureCollection, orderedExtraPropsMap } =
280+
createFeatureCollectionAndProps(odkFeatures);
281+
282+
expect(featureCollection).toEqual({
283+
type: 'FeatureCollection',
284+
features: [
285+
{
286+
type: 'Feature',
287+
geometry: {
288+
type: 'Point',
289+
coordinates: [-74.006, 40.7128],
290+
},
291+
properties: {
292+
odk___branchId: 'id-abc',
293+
odk___trunkVersion: 'v1.1.1',
294+
odk___version: 'v34.29.7',
295+
odk_geometry: '40.7128 -74.0060 100 5',
296+
odk_label: 'Point 1',
297+
odk_value: 'point1',
298+
},
299+
},
300+
],
301+
});
302+
303+
expect(orderedExtraPropsMap).toEqual(
304+
new Map([
305+
[
306+
'point1',
307+
[
308+
['clinic-name', 'New Hope Clinic'],
309+
['__clinic-id', '123456'],
310+
['another-prop', 'value2'],
311+
],
312+
],
313+
])
314+
);
315+
});
316+
267317
it('handles null label in ODK features', () => {
268318
const odkFeatures: SelectItem[] = [
269319
createSelectItem('point1', null, '40.7128 -74.0060 100 5', [['marker-color', '#ff0000']]),

0 commit comments

Comments
 (0)