Skip to content

Commit dfa15e2

Browse files
committed
Revert removal of M.geojson2mapml and M.mapml2geojson public API methods
Add test to confirm their existence
1 parent 9226b95 commit dfa15e2

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

src/mapml/GlobalM.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,9 @@ import './handlers/keyboard';
696696
}
697697
});
698698

699+
M.geojson2mapml = Util.geojson2mapml;
700+
M.mapml2geojson = Util.mapml2geojson;
701+
699702
// see https://leafletjs.com/examples/extending/extending-3-controls.html#handlers
700703
L.Map.addInitHook('addHandler', 'query', QueryHandler);
701704
L.Map.addInitHook('addHandler', 'contextMenu', ContextMenu);

test/e2e/geojson/geojson2mapml.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<body>
1313
<!--geojson2mapml layer output goes here dynamically-->
14-
<mapml-viewer id="output" projection="OSMTILE" zoom="10" lon="-75.7" lat="45.4" controls>
14+
<mapml-viewer data-testid="map" id="output" projection="OSMTILE" zoom="10" lon="-75.7" lat="45.4" controls>
1515
</mapml-viewer>
1616

1717
<!-- The expected results for geojson2mapml go here-->

test/e2e/geojson/geojson2mapml.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,15 @@ test.describe('GeoJSON API - geojson2mapml', () => {
158158
);
159159
expect(out).toEqual(exp);
160160
});
161+
test('M.geojson2mapml public API method exists and works', async ()=>{
162+
const viewer = page.getByTestId('map');
163+
await viewer.evaluate((v)=>{
164+
let l = M.geojson2mapml(point, {label: 'M.geojson2mapml public API method works'});
165+
v.appendChild(l);
166+
l.setAttribute('data-testid','test-layer');
167+
});
168+
const layer = page.getByTestId('test-layer');
169+
await expect(layer).not.toHaveAttribute('disabled');
170+
await expect(layer).toHaveAttribute('label','M.geojson2mapml public API method works');
171+
});
161172
});

test/e2e/geojson/mapml2geojson.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<!--All the mapml layers- that will be converted to geojson go in the mapml-viewer-->
1414
<mapml-viewer projection="OSMTILE" zoom="10" lon="-75.7" lat="45.4" controls>
1515

16-
<layer- label="Point Geometry" checked>
16+
<layer- data-testid="point" label="Point Geometry" checked>
1717
<map-feature>
1818
<map-featurecaption>Point</map-featurecaption>
1919
<map-geometry>

test/e2e/geojson/mapml2geojson.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,11 @@ test.describe('GeoJSON API - mapml2geojson', () => {
125125
);
126126
expect(out10).toEqual(exp10);
127127
});
128+
test('M.mapml2geojson public API method exists and works', async () => {
129+
const geojsonPoint = await page.evaluate(() => {
130+
let layer = document.querySelector('[data-testid=point]');
131+
return M.mapml2geojson(layer);
132+
});
133+
expect(geojsonPoint.title).toEqual('Point Geometry');
134+
});
128135
});

0 commit comments

Comments
 (0)