const assert = require("node:assert");
const CookieCode = require("../dist/cookiecode.js");
CookieCode.configurer({ sortie: "test", afficherNotions: true });
const texteRecette = CookieCode.recette("Cookie au chocolat")
.prendre("farine", 200, "g")
.prendre("sucre", 100, "g")
.utiliser("saladier")
.ajouter("farine")
.melanger()
.repeter(2, (recette) => {
recette.melanger();
})
.cuire(12, "minutes")
.toText();
assert.match(texteRecette, /Recette : Cookie au chocolat/);
assert.match(texteRecette, /1\. Prendre 200 g de farine\./);
assert.match(texteRecette, /2\. Prendre 100 g de sucre\./);
assert.match(texteRecette, /3\. Utiliser saladier\./);
assert.match(texteRecette, /6\. Repeter 2 fois :/);
assert.match(texteRecette, /6\.1\. Melanger\./);
assert.match(texteRecette, /Ingredients = variables : farine, sucre/);
assert.match(texteRecette, /Materiel \/ valeurs fixes = constantes : saladier/);
assert.match(texteRecette, /Repeter = boucle/);
const pate = CookieCode.preparation("pate").definir("texture", "trop seche");
const texteCondition = CookieCode.recette("Pate a cookies")
.si(
() => pate.est("trop seche"),
(recette) => {
recette.ajouter("lait", 20, "ml");
},
)
.toText();
assert.match(texteCondition, /Si condition fournie :/);
assert.match(texteCondition, /1\.1\. Ajouter 20 ml de lait\./);
assert.match(texteCondition, /Si = condition/);
const html = CookieCode.recette("")
.ajouter("
")
.toHTML();
assert.ok(!html.includes("