batchCooking/apps/api/test/sources/sources-index.test.ts
Nicolas 82c09331dc refactor(api): regroupe test/ par sous-domaine, miroir de src/lib/
18 fichiers à plat -> recipe-matching/ (ingredient-matcher, recipe-
translation, tech-step-matcher — miroir de lib/recipe-matching/),
recipe-sources/ (json-ld-recipe, recipe-source, recipe-source-sync,
the-meal-db — miroir de lib/recipe-sources/), sources/ (sources,
sources-index — module + registration src/sources/index.ts).

Les tests par domaine API sans regroupement naturel (auth, health,
house, logger.service, planning, preferences, profile, recipe,
reference) restent à la racine de test/, un fichier par domaine — même
logique que jwt.ts/safe-profile.ts restés à la racine de lib/.

Chemins relatifs corrigés (../src/ -> ../../src/, ../test-support/ ->
../../test-support/ dans les fichiers déplacés qui appellent
resetDatabase). .mocharc.json ("test/**/*.test.ts") couvre déjà les
sous-dossiers, aucun changement de config nécessaire.

Vérifié : biome check, 303 tests API.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-21 11:27:06 +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");
});
});