1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-05 13:35:23 +02:00

feat: plural foods and units, and aliases (#2674)

* added plural names and alias tables to foods/units

* updated models to include plural names and aliases

* updated parser to include plural and aliases

* fixed migrations

* fixed recursive models

* added plural abbreviation to migration

* updated parser and display prop

* update displays to use plurals

* fix display edgecase and remove print

* added/updated display tests

* fixed model bug and added parser tests

* added tests for aliases

* added new plural options to data management page

* removed unique constraint

* made base dialog more customizable

* added alias management to food and unit data pages

* removed unused awaits

* 🧹
This commit is contained in:
Michael Genson 2023-11-14 09:39:07 -06:00 committed by GitHub
parent 4b55b838ed
commit d440d51ffe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 1181 additions and 104 deletions

View file

@ -48,4 +48,74 @@ describe(parseIngredientText.name, () => {
expect(parseIngredientText(ingredient, false)).not.toContain("<script>");
});
test("plural test : plural qty : use abbreviation", () => {
const ingredient = createRecipeIngredient({
quantity: 2,
unit: { id: "1", name: "tablespoon", pluralName: "tablespoons", abbreviation: "tbsp", pluralAbbreviation: "tbsps", useAbbreviation: true },
food: { id: "1", name: "diced onion", pluralName: "diced onions" }
});
expect(parseIngredientText(ingredient, false)).toEqual("2 tbsps diced onions");
});
test("plural test : plural qty : not abbreviation", () => {
const ingredient = createRecipeIngredient({
quantity: 2,
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)).toEqual("2 tablespoons diced onions");
});
test("plural test : single qty : use abbreviation", () => {
const ingredient = createRecipeIngredient({
quantity: 1,
unit: { id: "1", name: "tablespoon", pluralName: "tablespoons", abbreviation: "tbsp", pluralAbbreviation: "tbsps", useAbbreviation: true },
food: { id: "1", name: "diced onion", pluralName: "diced onions" }
});
expect(parseIngredientText(ingredient, false)).toEqual("1 tbsp diced onion");
});
test("plural test : single qty : not abbreviation", () => {
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)).toEqual("1 tablespoon diced onion");
});
test("plural test : small qty : use abbreviation", () => {
const ingredient = createRecipeIngredient({
quantity: 0.5,
unit: { id: "1", name: "tablespoon", pluralName: "tablespoons", abbreviation: "tbsp", pluralAbbreviation: "tbsps", useAbbreviation: true },
food: { id: "1", name: "diced onion", pluralName: "diced onions" }
});
expect(parseIngredientText(ingredient, false)).toEqual("0.5 tbsp diced onion");
});
test("plural test : small qty : not abbreviation", () => {
const ingredient = createRecipeIngredient({
quantity: 0.5,
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)).toEqual("0.5 tablespoon diced onion");
});
test("plural test : zero qty", () => {
const ingredient = createRecipeIngredient({
quantity: 0,
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)).toEqual("diced onions");
});
});