Mercurial > gemma
diff client/tests/unit/geo/geo.spec.js @ 677:3605af94d1ee
fix: prepare profile calculation algorithm fixed
The x-value of a point is determined according to its reference point
* in case of the first segment, it is the first element of the line string
* in case of consecutive segments it is the last point of the previous segment
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Wed, 19 Sep 2018 16:37:03 +0200 |
parents | 4c36b0e39d78 |
children | 87ea9d267c2b |
line wrap: on
line diff
--- a/client/tests/unit/geo/geo.spec.js Wed Sep 19 16:09:09 2018 +0200 +++ b/client/tests/unit/geo/geo.spec.js Wed Sep 19 16:37:03 2018 +0200 @@ -330,9 +330,20 @@ o = o.concat(y); return o; }, []); + const growing = values => { + let first = values[0].x; + for (let v of values) { + if (first > v.x) return false; + } + return true; + }; const minAlt = Math.min(...alts); const maxAlt = Math.max(...alts); expect(result.points.length).toBe(3); + expect(growing(result.points[0])).toBe(true); + expect(growing(result.points[1])).toBe(true); + expect(growing([...result.points[0], ...result.points[1]])).toBe(true); + expect(growing([...result.points[1], ...result.points[2]])).toBe(false); // because of corrupt testdata expect(result.totalLength).toBe(160.06814078495722); expect(result.minAlt).toBe(minAlt); expect(result.maxAlt).toBe(maxAlt);