Skip to content

Commit

Permalink
unit test to check if token added to glyphs
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinr-maps committed Aug 7, 2023
1 parent b0d7815 commit 2d5baf7
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions spec/UtilSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,67 @@ describe('Util', function () {

expect(style.sprite).to.equal(`${spriteUrl}?token=${token}`);
});

it('should include the token in the glyph URL when the the URL does not start with http', function () {
const token = 'asdf';
const styleUrl =
'https://tiles.arcgis.com/tiles/test/arcgis/rest/services/test/VectorTileServer/resources/styles/root.json';
const fullGlyphUrl =
'https://tiles.arcgis.com/tiles/test/arcgis/rest/services/test/VectorTileServer/resources/fonts/{fontstack}/{range}.pbf';

const style = L.esri.Vector.Util.formatStyle(
{
version: 8,
sprite: 'https://www.arcgis.com/sharing/rest/content/items/123456789/resources/sprites/sprite-1679474043120',
glyphs: '../fonts/{fontstack}/{range}.pbf',
sources: {
esri: {
type: 'vector',
attribution: 'test',
bounds: [-180, -85.0511, 180, 85.0511],
minzoom: 0,
maxzoom: 19,
scheme: 'xyz',
url: '../../'
}
},
layers: []
},
styleUrl,
metadata,
token
);

expect(style.glyphs).to.equal(`${fullGlyphUrl}?token=${token}`);
});

it('should include the token in the glyph URL when the the URL does start with http', function () {
const token = 'asdf';
const glyphUrl = 'https://tiles.arcgis.com/tiles/U2DMZtrcqfn913et/arcgis/rest/services/DynamicConsumerMapWebMercator/VectorTileServer/resources/fonts/{fontstack}/{range}.pbf';

const style = L.esri.Vector.Util.formatStyle(
{
version: 8,
sprite: 'https://www.arcgis.com/sharing/rest/content/items/123456789/resources/sprites/sprite-1679474043120',
glyphs: glyphUrl,
sources: {
esri: {
type: 'vector',
attribution: 'test',
bounds: [-180, -85.0511, 180, 85.0511],
minzoom: 0,
maxzoom: 19,
scheme: 'xyz',
url: '../../'
}
},
layers: []
},
'nope',
metadata,
token
);

expect(style.glyphs).to.equal(`${glyphUrl}?token=${token}`);
});
});

0 comments on commit 2d5baf7

Please sign in to comment.