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:
parent
82d726bc14
commit
ee87a55fdd
1 changed files with 13 additions and 1 deletions
|
|
@ -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", () => {
|
describe("gpxToFitCourse", () => {
|
||||||
for (const fixture of FIXTURES) {
|
for (const fixture of FIXTURES) {
|
||||||
|
|
@ -67,6 +71,14 @@ describe("gpxToFitCourse", () => {
|
||||||
await expect(gpxToFitCourse({ gpx, name: "Empty" })).rejects.toThrow(/zero track points/);
|
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 () => {
|
it("advertises position+distance course capabilities (not time-only)", async () => {
|
||||||
const gpx = await loadFixture("short-flat.gpx");
|
const gpx = await loadFixture("short-flat.gpx");
|
||||||
const bytes = await gpxToFitCourse({ gpx, name: "Caps", sport: "cycling" });
|
const bytes = await gpxToFitCourse({ gpx, name: "Caps", sport: "cycling" });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue