feat: annotate scaled ingredient quantities

Refs #1, #2
This commit is contained in:
2026-08-14 13:28:39 -05:00
parent de8eab9022
commit b61ca70bed
2 changed files with 52 additions and 15 deletions
+18 -1
View File
@@ -1,6 +1,6 @@
const test = require("node:test");
const assert = require("node:assert/strict");
const { parseYield, scaleIngredient, scaleRecipe } = require("../lib/recipe-scaler");
const { parseYield, scaleIngredient, scaleIngredientWithStatus, scaleRecipe } = require("../lib/recipe-scaler");
test("extracts the number of portions from a recipe yield", () => {
assert.equal(parseYield("6 servings"), 6);
@@ -25,4 +25,21 @@ test("returns a scaled copy of a recipe", () => {
assert.equal(scaled.recipeYield, "9 servings");
assert.deepEqual(scaled.recipeIngredient, ["3 cups oats", "Salt to taste"]);
assert.equal(original.recipeYield, "6 servings");
assert.equal(scaled.originalRecipeYield, "6 servings");
assert.deepEqual(scaled.recipeIngredientStatus, ["scaled", "unquantified"]);
});
test("reports ingredient scaling confidence", () => {
assert.deepEqual(scaleIngredientWithStatus("2 cups oats", 1.5), {
value: "3 cups oats", status: "scaled"
});
assert.deepEqual(scaleIngredientWithStatus("Salt to taste", 2), {
value: "Salt to taste", status: "unquantified"
});
assert.deepEqual(scaleIngredientWithStatus("1-2 tbsp oil", 2), {
value: "1-2 tbsp oil", status: "unscalable"
});
assert.deepEqual(scaleIngredientWithStatus("1 cup milk", 0.7), {
value: "0.7 cup milk", status: "approximate"
});
});