Skip to content

Commit

Permalink
test: create new describe for tests that use the maplibre map object
Browse files Browse the repository at this point in the history
  • Loading branch information
boeckMt committed Mar 15, 2024
1 parent ac49d7b commit 5e3483c
Showing 1 changed file with 38 additions and 30 deletions.
68 changes: 38 additions & 30 deletions projects/map-maplibre/src/lib/maplibre-layers.helpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,37 +196,8 @@ const createLayers = () => {
}

describe('MaplibreLayerHelpers', () => {
let service: MapMaplibreService;
let map: glMap;

beforeEach(async () => {
TestBed.configureTestingModule({});
service = TestBed.inject(MapMaplibreService);
createLayers();

const baseStyle: StyleSpecification = {
"version": 8,
"name": "Merged Style Specifications",
"metadata": {
},
"sources": {},
"sprite": "https://openmaptiles.github.io/positron-gl-style/sprite",
"glyphs": "http://fonts.openmaptiles.org/{fontstack}/{range}.pbf",
"layers": []
};

const mapTarget = createMapTarget([1024, 768]);
map = new glMap({
container: mapTarget.container,
style: baseStyle as StyleSpecification
});

// https://github.com/maplibre/maplibre-gl-js/discussions/2193
await new Promise((resolve, reject) => {
map.once('idle', (evt) => {
resolve(evt);
});
});
});

it('should create ukis Metadata for LayerSourceSpecification', () => {
Expand Down Expand Up @@ -299,7 +270,7 @@ describe('MaplibreLayerHelpers', () => {

const geomTypes = ukisGeoJson.data.features.map(i => i.geometry.type);
const uniqueGeomTypes = geomTypes.filter((t, i) => geomTypes.findIndex(t2 => t2 === t) === i);

const geoJsonLayers = ls.layers.map(l => l.id);
// This is not true if there is only one polygon in the features, then there is one more layer.
expect(uniqueGeomTypes.length).toEqual(geoJsonLayers.length);
Expand Down Expand Up @@ -367,4 +338,41 @@ describe('MaplibreLayerHelpers', () => {


// TODO:createStackedLayer
});

describe('MaplibreLayerHelpers - use mapservice', () => {
let service: MapMaplibreService;
let map: glMap;

beforeEach(async () => {
TestBed.configureTestingModule({});
service = TestBed.inject(MapMaplibreService);
createLayers();

const baseStyle: StyleSpecification = {
"version": 8,
"name": "Merged Style Specifications",
"metadata": {
},
"sources": {},
"sprite": "https://openmaptiles.github.io/positron-gl-style/sprite",
"glyphs": "http://fonts.openmaptiles.org/{fontstack}/{range}.pbf",
"layers": []
};

const mapTarget = createMapTarget([1024, 768]);
map = new glMap({
container: mapTarget.container,
style: baseStyle as StyleSpecification
});

// https://github.com/maplibre/maplibre-gl-js/discussions/2193
await new Promise((resolve, reject) => {
map.once('idle', (evt) => {
resolve(evt);
});
});
});


});

0 comments on commit 5e3483c

Please sign in to comment.