From b48a6cf93abdce830df34af5088daf16f902b685 Mon Sep 17 00:00:00 2001 From: ftoromanoff Date: Fri, 5 Jan 2024 15:39:04 +0100 Subject: [PATCH] refactor(test): move test colorLayer to own test file --- test/unit/colorlayer.js | 37 +++++++++++++++++++++++++++++++++++++ test/unit/layer.js | 35 ----------------------------------- 2 files changed, 37 insertions(+), 35 deletions(-) create mode 100644 test/unit/colorlayer.js diff --git a/test/unit/colorlayer.js b/test/unit/colorlayer.js new file mode 100644 index 0000000000..39894c9ddc --- /dev/null +++ b/test/unit/colorlayer.js @@ -0,0 +1,37 @@ +import assert from 'assert'; +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('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); + }); +}); diff --git a/test/unit/layer.js b/test/unit/layer.js index c12406bdf8..1b2c5dd616 100644 --- a/test/unit/layer.js +++ b/test/unit/layer.js @@ -1,11 +1,6 @@ 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 () { @@ -72,33 +67,3 @@ 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); - }); -});