forked from MapComplete/MapComplete
Merge develop
This commit is contained in:
commit
ac1b4a010c
40 changed files with 5706 additions and 4746 deletions
|
@ -3,6 +3,7 @@ import {equal} from "assert";
|
|||
import T from "./TestHelper";
|
||||
import {GeoOperations} from "../Logic/GeoOperations";
|
||||
import {BBox} from "../Logic/BBox";
|
||||
import * as turf from "@turf/turf"
|
||||
|
||||
export default class GeoOperationsSpec extends T {
|
||||
|
||||
|
@ -187,7 +188,7 @@ export default class GeoOperationsSpec extends T {
|
|||
],
|
||||
["Regression test: intersection/overlap", () => {
|
||||
|
||||
const polyGrb ={
|
||||
const polyGrb = {
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"osm_id": "25189153",
|
||||
|
@ -351,10 +352,15 @@ export default class GeoOperationsSpec extends T {
|
|||
}
|
||||
}
|
||||
|
||||
const p0 = turf.polygon(polyGrb.geometry.coordinates)
|
||||
Assert.notEqual(p0, null)
|
||||
const p1 = turf.polygon(polyHouse.geometry.coordinates)
|
||||
Assert.notEqual(p1, null)
|
||||
|
||||
const overlaps = GeoOperations.calculateOverlap(polyGrb, [polyHouse])
|
||||
Assert.equal(overlaps.length, 1)
|
||||
const overlapsRev= GeoOperations.calculateOverlap(polyHouse, [polyGrb])
|
||||
Assert.equal(overlaps.length, 1)
|
||||
Assert.equal(overlaps.length, 0)
|
||||
const overlapsRev = GeoOperations.calculateOverlap(polyHouse, [polyGrb])
|
||||
Assert.equal(overlapsRev.length, 0)
|
||||
|
||||
}]
|
||||
]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
export default class T {
|
||||
|
||||
public readonly name: string;
|
||||
private readonly _tests: [string, (() => void)][];
|
||||
private readonly _tests: [string, (() => (void | Promise<void>))][];
|
||||
|
||||
constructor(testsuite: string, tests: [string, () => void][]) {
|
||||
constructor(testsuite: string, tests: [string, () => (Promise<void> | void)][]) {
|
||||
this.name = testsuite
|
||||
this._tests = tests;
|
||||
}
|
||||
|
@ -56,11 +56,18 @@ export default class T {
|
|||
* Returns an empty list if successful
|
||||
* @constructor
|
||||
*/
|
||||
public Run(): ({ testsuite: string, name: string, msg: string } []) {
|
||||
public Run(): { testsuite: string, name: string, msg: string } [] {
|
||||
const failures: { testsuite: string, name: string, msg: string } [] = []
|
||||
for (const [name, test] of this._tests) {
|
||||
try {
|
||||
test();
|
||||
const r = test()
|
||||
if (r instanceof Promise) {
|
||||
r.catch(e => {
|
||||
console.log("ASYNC ERROR: ", e, e.stack)
|
||||
failures.push({testsuite: this.name, name: name, msg: "" + e});
|
||||
});
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.log("ERROR: ", e, e.stack)
|
||||
failures.push({testsuite: this.name, name: name, msg: "" + e});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue