diff --git a/test/unit/featuregeometrylayer.js b/test/unit/featuregeometrylayer.js index 8f1178e1a3..670c6a8c82 100644 --- a/test/unit/featuregeometrylayer.js +++ b/test/unit/featuregeometrylayer.js @@ -131,5 +131,10 @@ describe('Layer with Feature process', function () { done(); }).catch(done); }); -}); + it('invalidate cache', function () { + ariege.invalidateCache(); + assert.equal(ariege.parent.level0Nodes[0].redraw, true); + assert.equal(ariege.parent.level0Nodes[0].layerUpdateState[ariege.id], undefined); + }); +}); diff --git a/test/unit/layer.js b/test/unit/layer.js index 1b2c5dd616..c12406bdf8 100644 --- a/test/unit/layer.js +++ b/test/unit/layer.js @@ -1,6 +1,11 @@ import assert from 'assert'; import Layer, { ImageryLayers } from 'Layer/Layer'; import ColorLayer from 'Layer/ColorLayer'; +import GlobeView from 'Core/Prefab/GlobeView'; +import FileSource from 'Source/FileSource'; +import Coordinates from 'Core/Geographic/Coordinates'; +import HttpsProxyAgent from 'https-proxy-agent'; +import Renderer from './bootstrap'; describe('Layer', function () { it('should emit an event on property changed', function () { @@ -67,3 +72,33 @@ describe('ImageryLayers', function () { assert.throws(() => new ColorLayer('id'), /^Error: Layer id needs Source$/); }); }); + +describe('ColorLayer', function () { + const renderer = new Renderer(); + const placement = { coord: new Coordinates('EPSG:4326', 1.5, 43), range: 300000 }; + const viewer = new GlobeView(renderer.domElement, placement, { renderer }); + + const source = new FileSource({ + url: 'https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson', + crs: 'EPSG:4326', + format: 'application/json', + networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {}, + }); + + const ariege = new ColorLayer('ariege', { + transparent: true, + style: { + fill: { color: 'blue', opacity: 0.8 }, + stroke: { color: 'black', width: 1.0 }, + }, + source, + zoom: { min: 11 }, + }); + viewer.addLayer(ariege); + + it('invalidate cache', function () { + ariege.invalidateCache(); + assert.equal(ariege.parent.level0Nodes[0].redraw, true); + assert.equal(ariege.parent.level0Nodes[0].layerUpdateState[ariege.id], undefined); + }); +});