Skip to content

Commit

Permalink
trying to add util unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinr-maps committed Jul 26, 2023
1 parent cad5b19 commit e128460
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/UtilSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-env mocha */

describe('Util', function () {
it('should include the token in the sprite URL when the the URL does not start with http', function () {
const spriteUrl = "../sprites/sprite"
const token = "asdf";

const style = L.esri.Vector.Util.formatStyle({"version":8,"sprite":spriteUrl,"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":[]}, "nope", {}, token);

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

it('should include the token in the sprite URL when the the URL does start with http', function () {
const spriteUrl = "https://www.arcgis.com/sharing/rest/content/items/123456789/resources/sprites/sprite-1679474043120"
const token = "asdf";

const style = L.esri.Vector.Util.formatStyle({"version":8,"sprite":spriteUrl,"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":[]}, "nope", {}, token);

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

0 comments on commit e128460

Please sign in to comment.