Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b54e58c99a |
No files matched your search
@@ -69,6 +69,7 @@
|
||||
"copy-webpack-plugin": "^14.0.0",
|
||||
"eslint": "^9",
|
||||
"eslint-config-next": "^16.2.6",
|
||||
"fast-check": "^4.8.0",
|
||||
"jsdom": "^28.1.0",
|
||||
"rollup-plugin-external-globals": "^0.13.0",
|
||||
"tsx": "^4.21.0",
|
||||
|
||||
Generated
+16
@@ -144,6 +144,9 @@ importers:
|
||||
eslint-config-next:
|
||||
specifier: ^16.2.6
|
||||
version: 16.2.6(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])
|
||||
fast-check:
|
||||
specifier: ^4.8.0
|
||||
version: 4.8.0
|
||||
jsdom:
|
||||
specifier: ^28.1.0
|
||||
version: 28.1.0
|
||||
@@ -3373,6 +3376,10 @@ packages:
|
||||
resolution: {integrity: sha512-h5+1OzzfCC3Ef7VbtKdcv7zsstUQwUDlYpUTvjeUsJAssPgLn7QzbboPtL5ro04Mq0rPOsMzl7q5hIbRs2wD1A==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-GOJ158CUMnN6cSahsv4+ExARvIDuzzinFjkp0E9WtiBa5zcVeLozVkWaE4IzFcc+Y48Wp1EDlUZsXRyAztQcSg==}
|
||||
engines: {node: '>=12.17.0'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
|
||||
|
||||
@@ -4589,6 +4596,9 @@ packages:
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-IoM8YF/jY0hiugFo/wOWqfmarlE6J0wc6fDK1PhftMk7MGhVZl88sZimmqBBFomLOCSmcCCpsfj7wXASCpvK9A==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-mzR4sElr1bfCaPJe7m8ilJ6ZXdDaGoObcYR0ZHSsktM/Lt21MVHj5De30GQH2eiZ1qGRTO7LCAzQsUeXTNexWQ==}
|
||||
engines: {node: '>=0.6'}
|
||||
@@ -8650,6 +8660,10 @@ snapshots:
|
||||
dependencies:
|
||||
pure-rand: 6.1.0
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
pure-rand: 8.4.0
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
@@ -9851,6 +9865,8 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { describe, test, expect } from "vitest";
|
||||
import { normalizeToGeoJson } from "./normalizer";
|
||||
import fc from "fast-check";
|
||||
|
||||
describe("normalizeToGeoJson", () => {
|
||||
test("passes through a valid FeatureCollection", () => {
|
||||
@@ -161,4 +162,37 @@ describe("normalizeToGeoJson", () => {
|
||||
test("throws on unrecognized format", () => {
|
||||
expect(() => normalizeToGeoJson({ foo: "bar" })).toThrow("Unrecognized");
|
||||
});
|
||||
|
||||
test("property: handles random coordinate inputs autonomously", () => {
|
||||
// This property test autonomously generates random float pairs to test edge-cases
|
||||
fc.assert(
|
||||
fc.property(
|
||||
fc.float({ noDefaultInfinity: true, noNaN: true }),
|
||||
fc.float({ noDefaultInfinity: true, noNaN: true }),
|
||||
(lon, lat) => {
|
||||
const input = {
|
||||
type: "Feature",
|
||||
geometry: { type: "Point", coordinates: [lon, lat] },
|
||||
properties: {},
|
||||
};
|
||||
|
||||
try {
|
||||
const result = normalizeToGeoJson(input);
|
||||
// normalizer skips coordinates outside valid bounds [-180, 180], [-90, 90]
|
||||
if (lon < -180 || lon > 180 || lat < -90 || lat > 90) {
|
||||
expect(result.skippedCount).toBe(1);
|
||||
} else {
|
||||
expect(result.skippedCount).toBe(0);
|
||||
expect(result.collection.features[0].geometry.coordinates).toEqual([lon, lat]);
|
||||
}
|
||||
} catch (e: any) {
|
||||
// Normalizer explicitly throws if ALL features are skipped
|
||||
if (e.message !== "No features with valid geometry found.") {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user