Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Scaled Ingredients Not Changing to Plural #2726

10 changes: 10 additions & 0 deletions frontend/composables/recipes/use-recipe-ingredients.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
4 changes: 2 additions & 2 deletions frontend/composables/recipes/use-recipe-ingredients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";

Expand Down
Loading