Every package now has tests — no more empty test suites: - map-core: 33 tests — maxspeedColor, routeGradeColor, elevationColor, POI categories, getCategoriesForProfile, tile layer configs - db: 5 tests — withDb error handling (503 on DB error, re-throws Response/DataWithResponseInit, logs errors) - ui: 14 tests — Button variants/sizes/disabled, Input label/id/error, Card className forwarding - map: 2 tests — baseLayers/overlayLayers re-export verification Remove passWithNoTests from vitest.shared.ts so missing tests are caught immediately when adding new packages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { poiCategories, getCategoriesForProfile, profileOverlayDefaults } from "./poi.ts";
|
|
|
|
describe("poiCategories", () => {
|
|
it("has expected categories", () => {
|
|
const ids = poiCategories.map((c) => c.id);
|
|
expect(ids).toContain("drinking_water");
|
|
expect(ids).toContain("camping");
|
|
expect(ids).toContain("food");
|
|
expect(ids).toContain("bike_infra");
|
|
});
|
|
|
|
it("every category has required fields", () => {
|
|
for (const cat of poiCategories) {
|
|
expect(cat.id).toBeTruthy();
|
|
expect(cat.name).toBeTruthy();
|
|
expect(cat.icon).toBeTruthy();
|
|
expect(cat.color).toMatch(/^#[0-9a-fA-F]{6}$/);
|
|
expect(cat.query).toBeTruthy();
|
|
}
|
|
});
|
|
});
|
|
|
|
describe("getCategoriesForProfile", () => {
|
|
it("returns trekking-specific categories", () => {
|
|
const ids = getCategoriesForProfile("trekking");
|
|
expect(ids).toContain("shelter");
|
|
expect(ids).toContain("viewpoints");
|
|
expect(ids).not.toContain("bike_infra");
|
|
});
|
|
|
|
it("returns cycling-specific categories", () => {
|
|
const ids = getCategoriesForProfile("fastbike");
|
|
expect(ids).toContain("bike_infra");
|
|
expect(ids).not.toContain("shelter");
|
|
});
|
|
|
|
it("returns empty array for unknown profile", () => {
|
|
expect(getCategoriesForProfile("unknown")).toEqual([]);
|
|
});
|
|
|
|
it("returns empty array for profiles with no dedicated categories", () => {
|
|
// Categories without profiles are available to everyone, not returned here
|
|
expect(getCategoriesForProfile("")).toEqual([]);
|
|
});
|
|
});
|
|
|
|
describe("profileOverlayDefaults", () => {
|
|
it("maps fastbike to cycling routes", () => {
|
|
expect(profileOverlayDefaults["fastbike"]).toContain("waymarked-cycling");
|
|
});
|
|
|
|
it("maps trekking to hiking routes", () => {
|
|
expect(profileOverlayDefaults["trekking"]).toContain("waymarked-hiking");
|
|
});
|
|
});
|