-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(examples): add new functional tests
- Loading branch information
1 parent
2d6abcd
commit 8e14fe8
Showing
3 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const assert = require('assert'); | ||
|
||
describe('source_file_kml_raster', function _() { | ||
let result; | ||
before(async () => { | ||
result = await loadExample('examples/source_file_kml_raster.html', this.fullTitle()); | ||
}); | ||
|
||
it('should run', async () => { | ||
assert.ok(result); | ||
}); | ||
|
||
it('load features data', async () => { | ||
const features = await page.evaluate(() => { | ||
const promises = []; | ||
const layers = view.getLayers(l => l.source && l.source.isFileSource); | ||
for (let i = 0; i < layers.length; i++) { | ||
promises.push(layers[i].source.loadData({}, { crs: 'EPSG:4326' })); | ||
} | ||
|
||
return Promise.all(promises); | ||
}); | ||
assert.equal(features.length, 2); // the layer and the LabelLayer | ||
assert.equal(features[0].uuid, features[1].uuid); | ||
}); | ||
|
||
it('should pick feature from Layer with SourceFile', async () => { | ||
const pickedFeatures = await page.evaluate(() => { | ||
/* global itowns */ | ||
const precision = view.getPixelsToDegrees(5); | ||
const geoCoord = new itowns.Coordinates('EPSG:4326', 6.80665, 45.91308, 0); | ||
const promises = []; | ||
const layers = view.getLayers(l => l.source && l.source.isFileSource); | ||
for (let i = 0; i < layers.length; i++) { | ||
promises.push( | ||
layers[i].source.loadData({}, { crs: 'EPSG:4326', buildExtent: false }) | ||
.then(fc => itowns.FeaturesUtils.filterFeaturesUnderCoordinate(geoCoord, fc, precision)), | ||
); | ||
} | ||
return Promise.all(promises); | ||
}); | ||
|
||
assert.equal(pickedFeatures.length, 2);// layer and the LabelLayer | ||
assert.equal(pickedFeatures[0].length, 1);// only 1 feature picked on layer | ||
assert.equal(pickedFeatures[1].length, 1);// and 1 on lableLayer | ||
assert.equal(pickedFeatures[0][0].geometry.properties.description, pickedFeatures[1][0].geometry.properties.description, 'same feature'); | ||
assert.equal(pickedFeatures[0][0].geometry.properties.description, 'Zone Aiguillette des Houches'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const assert = require('assert'); | ||
|
||
describe('source_file_kml_raster_usgs', function _() { | ||
let result; | ||
before(async () => { | ||
result = await loadExample('examples/source_file_kml_raster_usgs.html', this.fullTitle()); | ||
}); | ||
|
||
it('should run', async () => { | ||
assert.ok(result); | ||
}); | ||
|
||
it('load features data', async () => { | ||
const features = await page.evaluate(() => { | ||
const promises = []; | ||
const layers = view.getLayers(l => l.source && l.source.isFileSource); | ||
for (let i = 0; i < layers.length; i++) { | ||
promises.push(layers[i].source.loadData({}, { crs: 'EPSG:4326' })); | ||
} | ||
|
||
return Promise.all(promises); | ||
}); | ||
assert.equal(features.length, 2); // the layer and the LabelLayer | ||
assert.equal(features[0].uuid, features[1].uuid); | ||
assert.equal(features[0].features.length, 1); | ||
assert.equal(features[0].features[0].type, 0); | ||
}); | ||
}); |