Fix Biome warnings
This commit is contained in:
Vendored
+655
-655
File diff suppressed because it is too large
Load Diff
+20
-20
@@ -1,29 +1,29 @@
|
|||||||
CookieCode.configurer({
|
CookieCode.configurer({
|
||||||
sortie: "#app",
|
sortie: "#app",
|
||||||
afficherNotions: true,
|
afficherNotions: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const recette = CookieCode.recette("Cookie au chocolat")
|
const recette = CookieCode.recette("Cookie au chocolat")
|
||||||
.prendre("farine", 200, "g")
|
.prendre("farine", 200, "g")
|
||||||
.prendre("sucre", 100, "g")
|
.prendre("sucre", 100, "g")
|
||||||
.prendre("chocolat", 150, "g")
|
.prendre("chocolat", 150, "g")
|
||||||
.utiliser("saladier")
|
.utiliser("saladier")
|
||||||
.ajouter("farine")
|
.ajouter("farine")
|
||||||
.ajouter("sucre")
|
.ajouter("sucre")
|
||||||
.ajouter("chocolat")
|
.ajouter("chocolat")
|
||||||
.melanger()
|
.melanger()
|
||||||
.repeter(2, (recette) => {
|
.repeter(2, (recette) => {
|
||||||
recette.melanger();
|
recette.melanger();
|
||||||
})
|
})
|
||||||
.cuire(12, "minutes")
|
.cuire(12, "minutes")
|
||||||
.servir();
|
.servir();
|
||||||
|
|
||||||
const defi = CookieCode.defi("Cookie avec boucle", {
|
const defi = CookieCode.defi("Cookie avec boucle", {
|
||||||
ingredientsMinimum: 3,
|
ingredientsMinimum: 3,
|
||||||
actionsObligatoires: ["melanger", "cuire", "servir"],
|
actionsObligatoires: ["melanger", "cuire", "servir"],
|
||||||
boucleObligatoire: true,
|
boucleObligatoire: true,
|
||||||
terminerParServir: true,
|
terminerParServir: true,
|
||||||
interdireErreurs: true
|
interdireErreurs: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(CookieCode.verifier(recette, defi).toText());
|
console.log(CookieCode.verifier(recette, defi).toText());
|
||||||
|
|||||||
+16
-16
@@ -1,18 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name": "cookiecode",
|
"name": "cookiecode",
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"description": "Microlibrairie educative pour apprendre l'algorithmique avec des recettes de cuisine.",
|
"description": "Microlibrairie educative pour apprendre l'algorithmique avec des recettes de cuisine.",
|
||||||
"main": "dist/cookiecode.js",
|
"main": "dist/cookiecode.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node test/cookiecode.test.js",
|
"test": "node test/cookiecode.test.js",
|
||||||
"build": "cp src/cookiecode.js dist/cookiecode.js"
|
"build": "cp src/cookiecode.js dist/cookiecode.js"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"education",
|
"education",
|
||||||
"algorithmique",
|
"algorithmique",
|
||||||
"cuisine",
|
"cuisine",
|
||||||
"javascript",
|
"javascript",
|
||||||
"cdn"
|
"cdn"
|
||||||
],
|
],
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
|||||||
+655
-655
File diff suppressed because it is too large
Load Diff
+55
-43
@@ -1,19 +1,19 @@
|
|||||||
const assert = require("assert");
|
const assert = require("node:assert");
|
||||||
const CookieCode = require("../dist/cookiecode.js");
|
const CookieCode = require("../dist/cookiecode.js");
|
||||||
|
|
||||||
CookieCode.configurer({ sortie: "test", afficherNotions: true });
|
CookieCode.configurer({ sortie: "test", afficherNotions: true });
|
||||||
|
|
||||||
const texteRecette = CookieCode.recette("Cookie au chocolat")
|
const texteRecette = CookieCode.recette("Cookie au chocolat")
|
||||||
.prendre("farine", 200, "g")
|
.prendre("farine", 200, "g")
|
||||||
.prendre("sucre", 100, "g")
|
.prendre("sucre", 100, "g")
|
||||||
.utiliser("saladier")
|
.utiliser("saladier")
|
||||||
.ajouter("farine")
|
.ajouter("farine")
|
||||||
.melanger()
|
.melanger()
|
||||||
.repeter(2, (recette) => {
|
.repeter(2, (recette) => {
|
||||||
recette.melanger();
|
recette.melanger();
|
||||||
})
|
})
|
||||||
.cuire(12, "minutes")
|
.cuire(12, "minutes")
|
||||||
.toText();
|
.toText();
|
||||||
|
|
||||||
assert.match(texteRecette, /Recette : Cookie au chocolat/);
|
assert.match(texteRecette, /Recette : Cookie au chocolat/);
|
||||||
assert.match(texteRecette, /1\. Prendre 200 g de farine\./);
|
assert.match(texteRecette, /1\. Prendre 200 g de farine\./);
|
||||||
@@ -27,21 +27,21 @@ assert.match(texteRecette, /Repeter = boucle/);
|
|||||||
|
|
||||||
const pate = CookieCode.preparation("pate").definir("texture", "trop seche");
|
const pate = CookieCode.preparation("pate").definir("texture", "trop seche");
|
||||||
const texteCondition = CookieCode.recette("Pate a cookies")
|
const texteCondition = CookieCode.recette("Pate a cookies")
|
||||||
.si(
|
.si(
|
||||||
() => pate.est("trop seche"),
|
() => pate.est("trop seche"),
|
||||||
(recette) => {
|
(recette) => {
|
||||||
recette.ajouter("lait", 20, "ml");
|
recette.ajouter("lait", 20, "ml");
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.toText();
|
.toText();
|
||||||
|
|
||||||
assert.match(texteCondition, /Si condition fournie :/);
|
assert.match(texteCondition, /Si condition fournie :/);
|
||||||
assert.match(texteCondition, /1\.1\. Ajouter 20 ml de lait\./);
|
assert.match(texteCondition, /1\.1\. Ajouter 20 ml de lait\./);
|
||||||
assert.match(texteCondition, /Si = condition/);
|
assert.match(texteCondition, /Si = condition/);
|
||||||
|
|
||||||
const html = CookieCode.recette("<script>alert('xss')</script>")
|
const html = CookieCode.recette("<script>alert('xss')</script>")
|
||||||
.ajouter("<img src=x onerror=alert(1)>")
|
.ajouter("<img src=x onerror=alert(1)>")
|
||||||
.toHTML();
|
.toHTML();
|
||||||
|
|
||||||
assert.ok(!html.includes("<script>alert"));
|
assert.ok(!html.includes("<script>alert"));
|
||||||
assert.ok(!html.includes("<img src=x"));
|
assert.ok(!html.includes("<img src=x"));
|
||||||
@@ -49,18 +49,18 @@ assert.ok(html.includes("<script>alert"));
|
|||||||
assert.ok(html.includes("<img src=x"));
|
assert.ok(html.includes("<img src=x"));
|
||||||
|
|
||||||
const recetteDefi = CookieCode.recette("Cookie defi")
|
const recetteDefi = CookieCode.recette("Cookie defi")
|
||||||
.prendre("farine", 200, "g")
|
.prendre("farine", 200, "g")
|
||||||
.prendre("sucre", 100, "g")
|
.prendre("sucre", 100, "g")
|
||||||
.prendre("chocolat", 150, "g")
|
.prendre("chocolat", 150, "g")
|
||||||
.ajouter("farine")
|
.ajouter("farine")
|
||||||
.ajouter("sucre")
|
.ajouter("sucre")
|
||||||
.ajouter("chocolat")
|
.ajouter("chocolat")
|
||||||
.melanger()
|
.melanger()
|
||||||
.repeter(2, (recette) => {
|
.repeter(2, (recette) => {
|
||||||
recette.melanger();
|
recette.melanger();
|
||||||
})
|
})
|
||||||
.cuire(12, "minutes")
|
.cuire(12, "minutes")
|
||||||
.servir();
|
.servir();
|
||||||
|
|
||||||
const rapport = recetteDefi.analyser();
|
const rapport = recetteDefi.analyser();
|
||||||
assert.deepStrictEqual(rapport.ingredients, ["farine", "sucre", "chocolat"]);
|
assert.deepStrictEqual(rapport.ingredients, ["farine", "sucre", "chocolat"]);
|
||||||
@@ -70,11 +70,11 @@ assert.strictEqual(rapport.termineParServir, true);
|
|||||||
assert.deepStrictEqual(rapport.erreurs, []);
|
assert.deepStrictEqual(rapport.erreurs, []);
|
||||||
|
|
||||||
const defiCookie = CookieCode.defi("Cookie avec boucle", {
|
const defiCookie = CookieCode.defi("Cookie avec boucle", {
|
||||||
ingredientsMinimum: 3,
|
ingredientsMinimum: 3,
|
||||||
actionsObligatoires: ["melanger", "cuire", "servir"],
|
actionsObligatoires: ["melanger", "cuire", "servir"],
|
||||||
boucleObligatoire: true,
|
boucleObligatoire: true,
|
||||||
terminerParServir: true,
|
terminerParServir: true,
|
||||||
interdireErreurs: true,
|
interdireErreurs: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const verification = CookieCode.verifier(recetteDefi, defiCookie);
|
const verification = CookieCode.verifier(recetteDefi, defiCookie);
|
||||||
@@ -83,14 +83,26 @@ assert.match(verification.toText(), /Resultat : reussi/);
|
|||||||
assert.match(verification.toText(), /✅ Tu as utilise 3 ingredient\(s\)\./);
|
assert.match(verification.toText(), /✅ Tu as utilise 3 ingredient\(s\)\./);
|
||||||
|
|
||||||
const recetteIncomplete = CookieCode.recette("Cookie incomplet")
|
const recetteIncomplete = CookieCode.recette("Cookie incomplet")
|
||||||
.prendre("farine", 200, "g")
|
.prendre("farine", 200, "g")
|
||||||
.melanger();
|
.melanger();
|
||||||
|
|
||||||
const verificationIncomplete = CookieCode.verifier(recetteIncomplete, defiCookie);
|
const verificationIncomplete = CookieCode.verifier(
|
||||||
|
recetteIncomplete,
|
||||||
|
defiCookie,
|
||||||
|
);
|
||||||
assert.strictEqual(verificationIncomplete.reussi, false);
|
assert.strictEqual(verificationIncomplete.reussi, false);
|
||||||
assert.match(verificationIncomplete.toText(), /❌ Il faut au moins 3 ingredient\(s\)\./);
|
assert.match(
|
||||||
assert.match(verificationIncomplete.toText(), /❌ Il manque une boucle : essaie avec \.repeter\(\)\./);
|
verificationIncomplete.toText(),
|
||||||
assert.match(verificationIncomplete.toText(), /❌ Ta recette doit se terminer par \.servir\(\)\./);
|
/❌ Il faut au moins 3 ingredient\(s\)\./,
|
||||||
|
);
|
||||||
|
assert.match(
|
||||||
|
verificationIncomplete.toText(),
|
||||||
|
/❌ Il manque une boucle : essaie avec \.repeter\(\)\./,
|
||||||
|
);
|
||||||
|
assert.match(
|
||||||
|
verificationIncomplete.toText(),
|
||||||
|
/❌ Ta recette doit se terminer par \.servir\(\)\./,
|
||||||
|
);
|
||||||
|
|
||||||
assert.strictEqual(CookieCode.version, "0.2.0");
|
assert.strictEqual(CookieCode.version, "0.2.0");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user