Skip to content

Commit

Permalink
Revert removal of M.geojson2mapml and M.mapml2geojson public API methods
Browse files Browse the repository at this point in the history
Add test to confirm their existence
  • Loading branch information
prushforth committed Sep 19, 2024
1 parent 9226b95 commit c1ce3bf
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/mapml/GlobalM.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,9 @@ import './handlers/keyboard';
}
});

M.geojson2mapml = Util.geojson2mapml;
M.mapml2geojson = Util.mapml2geojson;

// see https://leafletjs.com/examples/extending/extending-3-controls.html#handlers
L.Map.addInitHook('addHandler', 'query', QueryHandler);
L.Map.addInitHook('addHandler', 'contextMenu', ContextMenu);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/geojson/geojson2mapml.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

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

<!-- The expected results for geojson2mapml go here-->
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/geojson/geojson2mapml.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,15 @@ test.describe('GeoJSON API - geojson2mapml', () => {
);
expect(out).toEqual(exp);
});
test('M.geojson2mapml public API method exists and works', async ()=>{
const viewer = page.getByTestId('map');
await viewer.evaluate((v)=>{
let l = M.geojson2mapml(point, {label: 'M.geojson2mapml public API method works'});
v.appendChild(l);
l.setAttribute('data-testid','test-layer');
});
const layer = page.getByTestId('test-layer');
await expect(layer).not.toHaveAttribute('disabled');
await expect(layer).toHaveAttribute('label','M.geojson2mapml public API method works');
});
});
2 changes: 1 addition & 1 deletion test/e2e/geojson/mapml2geojson.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<!--All the mapml layers- that will be converted to geojson go in the mapml-viewer-->
<mapml-viewer projection="OSMTILE" zoom="10" lon="-75.7" lat="45.4" controls>

<layer- label="Point Geometry" checked>
<layer- data-testid="point" label="Point Geometry" checked>
<map-feature>
<map-featurecaption>Point</map-featurecaption>
<map-geometry>
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/geojson/mapml2geojson.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,11 @@ test.describe('GeoJSON API - mapml2geojson', () => {
);
expect(out10).toEqual(exp10);
});
test('M.mapml2geojson public API method exists and works', async () => {
const geojsonPoint = await page.evaluate(() => {
let layer = document.querySelector('[data-testid=point]');
return M.mapml2geojson(layer);
});
expect(geojsonPoint.title).toEqual('Point Geometry');
});
});

0 comments on commit c1ce3bf

Please sign in to comment.