From bf107f0ed7f0e369d3818992c2031c02f0480635 Mon Sep 17 00:00:00 2001 From: Stepan Kuzmin Date: Fri, 1 May 2020 18:08:38 +0300 Subject: [PATCH] add tests for setUrl and setTiles #3709 --- test/unit/source/vector_tile_source.test.js | 33 ++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/test/unit/source/vector_tile_source.test.js b/test/unit/source/vector_tile_source.test.js index b3a00588805..0fbdcec3943 100644 --- a/test/unit/source/vector_tile_source.test.js +++ b/test/unit/source/vector_tile_source.test.js @@ -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) => { @@ -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(); });