test(fit): adapt single-point GPX case to the parser's <2-point drop

CI "Unit Tests" (full monorepo) caught that @trails-cool/fit's round-trip
fixture loop included single-point.gpx, which now parses to zero track
points (the parser drops <2-point segments), so gpxToFitCourse correctly
throws its zero-points guard. Drop single-point.gpx from the round-trip
loop and cover the degenerate case explicitly: a lone point → zero points
→ refused.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-07-14 00:16:55 +02:00
parent 82d726bc14
commit ee87a55fdd
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9

View file

@ -33,7 +33,11 @@ function decode(bytes: Uint8Array): Promise<ParsedFit> {
});
}
const FIXTURES = ["short-flat.gpx", "alpine.gpx", "multi-day.gpx", "single-point.gpx"] as const;
// single-point.gpx is intentionally excluded from the round-trip loop: the
// GPX parser now drops segments left with fewer than 2 points
// (gpx-parser-robustness), so a lone point yields zero track points and
// can't round-trip. That degenerate case is covered on its own below.
const FIXTURES = ["short-flat.gpx", "alpine.gpx", "multi-day.gpx"] as const;
describe("gpxToFitCourse", () => {
for (const fixture of FIXTURES) {
@ -67,6 +71,14 @@ describe("gpxToFitCourse", () => {
await expect(gpxToFitCourse({ gpx, name: "Empty" })).rejects.toThrow(/zero track points/);
});
it("drops a single-point GPX to zero points, so it is refused", async () => {
// The parser discards <2-point segments (gpx-parser-robustness), so a
// lone point can't form a FIT course — the zero-points guard fires.
const gpx = await loadFixture("single-point.gpx");
expect((await parseGpxAsync(gpx)).tracks.flat()).toHaveLength(0);
await expect(gpxToFitCourse({ gpx, name: "Single" })).rejects.toThrow(/zero track points/);
});
it("advertises position+distance course capabilities (not time-only)", async () => {
const gpx = await loadFixture("short-flat.gpx");
const bytes = await gpxToFitCourse({ gpx, name: "Caps", sport: "cycling" });