Skip to content

Commit

Permalink
add tests for setUrl and setTiles mapbox#3709
Browse files Browse the repository at this point in the history
  • Loading branch information
Stepan Kuzmin committed May 1, 2020
1 parent f56d09f commit bf107f0
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion test/unit/source/vector_tile_source.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function createSource(options, transformCallback) {
source.onAdd({
transform: {showCollisionBoxes: false},
_getMapId: () => 1,
_requestManager: new RequestManager(transformCallback)
_requestManager: new RequestManager(transformCallback),
style: {sourceCaches: {id: {clearTiles: () => {}}}}
});

source.on('error', (e) => {
Expand Down Expand Up @@ -326,5 +327,35 @@ test('VectorTileSource', (t) => {
t.end();
});

t.test('supports url property updates', (t) => {
const source = createSource({
url: "http://localhost:2900/source.json"
});
source.setUrl("http://localhost:2900/source2.json");
t.deepEqual(source.serialize(), {
type: 'vector',
url: "http://localhost:2900/source2.json"
});
t.end();
});

t.test('supports tiles property updates', (t) => {
const source = createSource({
minzoom: 1,
maxzoom: 10,
attribution: "Mapbox",
tiles: ["http://example.com/{z}/{x}/{y}.png"]
});
source.setTiles(["http://example2.com/{z}/{x}/{y}.png"]);
t.deepEqual(source.serialize(), {
type: 'vector',
minzoom: 1,
maxzoom: 10,
attribution: "Mapbox",
tiles: ["http://example2.com/{z}/{x}/{y}.png"]
});
t.end();
});

t.end();
});

0 comments on commit bf107f0

Please sign in to comment.