mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-05-24 01:12:54 -04:00
fix: Scaled Ingredients Not Changing to Plural (#2726)
* fixed food/unit not updating to plural when scaled * added test * fixed weird edgecase that appears only after edits --------- Co-authored-by: boc-the-git <3479092+boc-the-git@users.noreply.github.com>
This commit is contained in:
parent
cf00325c2b
commit
1f35a23bfa
@ -118,4 +118,14 @@ describe(parseIngredientText.name, () => {
|
||||
|
||||
expect(parseIngredientText(ingredient, false)).toEqual("diced onions");
|
||||
});
|
||||
|
||||
test("plural test : single qty, scaled", () => {
|
||||
const ingredient = createRecipeIngredient({
|
||||
quantity: 1,
|
||||
unit: { id: "1", name: "tablespoon", pluralName: "tablespoons", abbreviation: "tbsp", pluralAbbreviation: "tbsps", useAbbreviation: false },
|
||||
food: { id: "1", name: "diced onion", pluralName: "diced onions" }
|
||||
});
|
||||
|
||||
expect(parseIngredientText(ingredient, false, 2)).toEqual("2 tablespoons diced onions");
|
||||
});
|
||||
});
|
||||
|
@ -46,8 +46,8 @@ export function useParsedIngredientText(ingredient: RecipeIngredient, disableAmo
|
||||
}
|
||||
|
||||
const { quantity, food, unit, note } = ingredient;
|
||||
const usePluralUnit = quantity !== undefined && quantity > 1;
|
||||
const usePluralFood = (!quantity) || quantity > 1
|
||||
const usePluralUnit = quantity !== undefined && (quantity * scale > 1 || quantity * scale === 0);
|
||||
const usePluralFood = (!quantity) || quantity * scale > 1
|
||||
|
||||
let returnQty = "";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user