batchCooking/apps/api/test/sources-index.test.ts
Nicolas 4db8e1369f refactor(api): regroupe lib/ par sous-domaine au lieu d'un dossier à plat
9 fichiers à plat -> recipe-sources/ (recipe-source-adapter, recipe-source-
errors, recipe-source-registry) et recipe-matching/ (recipe-translation,
ingredient-matcher, tech-step-matcher). jwt.ts, safe-profile.ts et
logger.service.ts restent à la racine de lib/ (pas de sous-domaine
partagé avec les autres).

Chemins relatifs corrigés dans les fichiers déplacés (profondeur +1 vers
db/) et chez tous leurs importeurs (modules/sources, modules/recipe,
sources/*, db/recipe-source-sync.ts, 12 fichiers de test), doc mise à
jour (specs/backend-architecture.md, specs/batch-cooking-architecture.md).

Vérifié : tsc --noEmit, biome check, build complet, 303 tests API.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-21 11:21:49 +02:00

34 lines
1.3 KiB
TypeScript

import { expect } from "chai";
import {
clearRecipeSources,
getRecipeSource,
listRecipeSources,
} from "../src/lib/recipe-sources/recipe-source-registry.js";
import { registerAllRecipeSources } from "../src/sources/index.js";
// Not exercised by any other test file — `registerAllRecipeSources` is
// deliberately never imported by `app.ts` (see its own doc comment), so
// nothing else in the suite triggers it. Registers/clears explicitly here
// rather than relying on module-load order, so this test's outcome doesn't
// depend on which other test file Mocha happens to load first.
describe("registerAllRecipeSources", () => {
afterEach(() => {
clearRecipeSources();
});
it("registers TheMealDB into the shared registry", () => {
registerAllRecipeSources();
const theMealDb = getRecipeSource("theMealDb");
expect(theMealDb).to.not.be.undefined;
expect(theMealDb?.name).to.equal("TheMealDB");
expect(listRecipeSources().map((adapter) => adapter.key)).to.include("theMealDb");
});
it("does not register the generic JSON-LD adapter — it's not a household-toggleable source in its own right", () => {
registerAllRecipeSources();
expect(getRecipeSource("jsonLdRecipe")).to.be.undefined;
expect(listRecipeSources().map((adapter) => adapter.key)).to.not.include("jsonLdRecipe");
});
});