Skip to content

Commit

Permalink
refactor(test): add new unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
a-dutremble committed Jul 5, 2023
1 parent 8463268 commit cb66b44
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/unit/featuregeometrylayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
35 changes: 35 additions & 0 deletions test/unit/layer.js
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down Expand Up @@ -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);
});
});

0 comments on commit cb66b44

Please sign in to comment.