jsonLdRecipeAdapter était enregistré (et donc synchronisé comme Source sélectionnable par un foyer) au même titre que theMealDbAdapter — mais c'est une structure générique de parsing schema.org destinée à être déclinée par site web scrappé, pas une source qu'on peut raisonnablement « activer » ou « faire confiance » en tant que telle (aucun catalogue à parcourir : list() renvoie toujours vide). registerAllRecipeSources() ne l'enregistre donc plus — elle reste utilisable directement (un futur adapter par site l'utiliserait en interne, ou un futur flux « importer depuis une URL » l'appellerait directement), simplement plus comme Source autonome du registre. Corrige aussi le mock Cypress qui prétendait « mirrorer ce qui est vraiment seedé » avec cette même source — remplacé par un second exemple clairement illustratif (Marmiton), qui ne correspond à aucun adapter réel. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { expect } from "chai";
|
|
import {
|
|
clearRecipeSources,
|
|
getRecipeSource,
|
|
listRecipeSources,
|
|
} from "../src/lib/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");
|
|
});
|
|
});
|