Skip to content

Commit

Permalink
test: add test for updateLayers with updateStyleLayerProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
boeckMt committed Mar 15, 2024
1 parent 6b0c368 commit 3de8c9e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions projects/map-maplibre/src/lib/maplibre-layers.helpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,5 +384,27 @@ describe('MaplibreLayerHelpers - use mapservice', () => {
});
});

it('should update as StyleLayer', () => {
const filtertype = 'Layers';
const waterId = 'water';
const waterIdStyledObj = `${waterId}:${ukisCustom.id}`;
service.setUkisLayers([ukisCustom], filtertype, map);
const layerBeforUpdate = service.getLayersForId(ukisCustom.id, filtertype, map).styleLayers
const waterLayerBefor = layerBeforUpdate.find(l => l.id === waterIdStyledObj);

ukisCustom.visible = true;
const paintProp = 'fill-color'
const newColor = 'hsl(200, 100%, 30%)';
// TODO: service.setUkisLayers changes the id on the original object????
const waterLayer = ukisCustom.custom_layer.layers.find(l => l.id === waterId);
waterLayer.paint[paintProp] = newColor;
updateStyleLayerProperties(map, waterLayerBefor as TypedStyleLayer, ukisCustom)

const layerAfterUpdate = service.getLayersForId(ukisCustom.id, filtertype, map).styleLayers;
const waterLayerAfter = layerAfterUpdate.find(l => l.id === waterIdStyledObj);

expect(waterLayerAfter.visibility).toBe("visible");
expect(waterLayerAfter.getPaintProperty(paintProp)).toBe(newColor);
});

});

0 comments on commit 3de8c9e

Please sign in to comment.