forked from opengeos/GeoLibre
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisibility.test.ts
More file actions
64 lines (60 loc) · 1.92 KB
/
Copy pathvisibility.test.ts
File metadata and controls
64 lines (60 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { test, describe } from "node:test";
import assert from "node:assert";
import type { GeoLibreProject } from "@geolibre/core";
import { excludeHiddenFieldsFromProject } from "../packages/core/src/visibility";
describe("visibility", () => {
test("excludeHiddenFieldsFromProject strips excluded fields from geojson and embeddedGeoJSON", () => {
const project: GeoLibreProject = {
id: "proj-1",
name: "Test",
version: 1,
viewState: {
longitude: 0,
latitude: 0,
zoom: 0,
pitch: 0,
bearing: 0,
},
layers: [
{
id: "layer-1",
name: "Layer",
type: "geojson",
visible: true,
metadata: {
embeddedGeoJSON: {
type: "FeatureCollection",
features: [
{
type: "Feature",
geometry: { type: "Point", coordinates: [0, 0] },
properties: { keep: 1, drop: 2 },
},
],
},
},
fieldVisibility: { drop: "excluded" },
geojson: {
type: "FeatureCollection",
features: [
{
type: "Feature",
geometry: { type: "Point", coordinates: [0, 0] },
properties: { keep: 1, drop: 2 },
},
],
},
},
],
};
const stripped = excludeHiddenFieldsFromProject(project);
// Check main geojson
const feature1 = stripped.layers[0].geojson!.features[0];
assert.strictEqual(feature1.properties?.keep, 1);
assert.strictEqual(feature1.properties?.drop, undefined);
// Check embedded geojson
const embeddedFeature = (stripped.layers[0].metadata.embeddedGeoJSON as any).features[0];
assert.strictEqual(embeddedFeature.properties?.keep, 1);
assert.strictEqual(embeddedFeature.properties?.drop, undefined);
});
});