Skip to content

Commit

Permalink
test: shortbread style
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKreil committed Dec 10, 2023
1 parent 5c1cd2a commit 6f5f03f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/lib/shortbread/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function getTemplate(): MaplibreStyleVector {
sprite: 'https://tiles.versatiles.org/sprites/sprites',
sources: {
'versatiles-shortbread': {
tilejson: '3.0.0',
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
tiles: [
'https://tiles.versatiles.org/tiles/osm/{z}/{x}/{y}',
Expand Down
41 changes: 39 additions & 2 deletions src/lib/style_guesser.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */
import getTemplate from './shortbread/template.js';
import guessStyle from './style_guesser.js';
import type { VectorLayer } from './types.ts';
import type { VectorLayer } from './types.js';

describe('guessStyle', () => {
const tiles = ['https://example.com/tiles/{z}/{x}/{y}'];
Expand All @@ -16,7 +17,7 @@ describe('guessStyle', () => {
});
});

it('should build vector styles', () => {
it('should build vector inspector styles', () => {
const type = 'vector';
const format = 'pbf';
const vectorLayers: VectorLayer[] = [{ id: 'geometry', fields: { label: 'String', height: 'Number' } }];
Expand Down Expand Up @@ -58,4 +59,40 @@ describe('guessStyle', () => {
],
});
});

it('should build shortbread vector styles', () => {
const type = 'vector';
const format = 'pbf';
const vectorLayers = getTemplate().sources['versatiles-shortbread'].vector_layers;
const style = guessStyle({ tiles, format, vectorLayers, baseUrl: 'http://example.com' });

expect(style.layers.length).toBe(236);
style.layers = [];

expect(style).toStrictEqual({
glyphs: 'http://example.com/assets/fonts/{fontstack}/{range}.pbf',
metadata: {
license: 'https://creativecommons.org/publicdomain/zero/1.0/',
'maputnik:renderer': 'mbgljs',
},
name: 'versatiles-colorful',
sprite: 'http://example.com/assets/sprites/sprites',
layers: [],
sources: {
'versatiles-shortbread': {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
bounds: [-180, -85.0511287798066, 180, 85.0511287798066],
format,
maxzoom: 14,
minzoom: 0,
scheme: 'xyz',
tilejson: '3.0.0',
tiles,
type,
vector_layers: vectorLayers,
},
},
version: 8,
});
});
});

0 comments on commit 6f5f03f

Please sign in to comment.