Expand filters.js coverage + fix nearestPoint ESM regression - #5
Open
RichardLitt wants to merge 1 commit into
Open
Expand filters.js coverage + fix nearestPoint ESM regression#5RichardLitt wants to merge 1 commit into
RichardLitt wants to merge 1 commit into
Conversation
Adds ~50 tests to filters.test.js, bringing the total project test
count from 98 to 154. Covers every previously-untested export:
- orderByDate (5 tests): ascending sort, stable order, both
YYYY-MM-DD and MM/DD/YYYY input formats
- durationFilter (6 tests): inclusive boundary, opts.duration
optional, string/number duration values
- createPeriodArray (6 tests): per-period grouping, descending
SpeciesTotal sort, spuhs excluded from the count
- removeSpuh (13 tests): clean species, sp./hybrid/Domestic
filtering, trinomial truncation + Subspecies recording, reverse
mode (kept-everything semantics), reference-based dedup
- removeSpuhFromCounties (3 tests): county-keyed, non-empty per
county, no spuh markers in output
- pointLookup (5 tests): Burlington/Montpelier resolution,
out-of-state returns undefined, accepts both {Latitude,Longitude}
and GeoJSON Point shapes, also works for biophysical regions
- getPoint (4 tests): point inside, UPPERCASE LATITUDE/LONGITUDE
keys, nearest-in-county fallback for offshore points
- getTownCentroids (6 tests): 255 features for all VT towns,
single feature for a named town, West Haven centroid lands in
VT (regression test for the centerOfMass -> turf.center fix),
Point geometry type, undefined for unknown town
Also extends existing coverage:
- dateFilter (+3): number vs string year, strict after boundary,
zero-match returns empty
- completeChecklistFilter (+4): noIncidental drops Incidental /
Historical, accepts both 1 and "1" for All Obs Reported
- locationFilter (+3): populates Country, populates Region,
discards no-Latitude records
Production fix: filters.js:89 was calling nearestPoint.default(...)
which worked when @turf/nearest-point was loaded via CommonJS
(.default exposed by the CJS interop wrapper) but threw "default
is not a function" in ESM. Changed to nearestPoint(...) -- the
ESM default import IS the function. The getPoint fallback (for
points on rivers / borders) was effectively broken on the
esm-migration branch until this fix; the new test for that
fallback path would have surfaced the regression.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacks on #4. Brings project test count from 98 to 154 (+56 tests). Covers every previously-untested export in
filters.jsand extends the existing coverage:New coverage
orderByDatedurationFiltercreatePeriodArrayremoveSpuhremoveSpuhFromCountiespointLookupgetPointgetTownCentroidsturf.centerfixExtended existing coverage
dateFilter+3 (number vs string year, strictisAfter, zero-match)completeChecklistFilter+4 (noIncidental drops Incidental + Historical)locationFilter+3 (populates Country, Region, discards no-Latitude records)Production fix included
filters.js:89was callingnearestPoint.default(...), which worked under CommonJS (the interop wrapper exposed.defaulton the module export) but threwdefault is not a functionin ESM. Changed tonearestPoint(...)— the ESM default import IS the function.This is a real ESM-migration regression caught by the new
getPointfallback test. Without this fix,locationFilter(which usesgetPointfor points on rivers / borders) would silently log errors and miss those checklists.Test plan
npm test— 154 pass + 2 todo, 0 failStack
Base:
tests-appears-during-expected-dates(#4). GitHub auto-retargets up the stack as PRs merge.