fix: ignore case when checking for an existing alias (#9025)
This commit is contained in:
1 parent
731676f007
commit
085cc604cd
2 files changed
+28
-2
No files matched your search
@@ -594,6 +594,18 @@ describe("useParseIngredientsDialog", () => {
|
||||
await addMissingUnitAsAlias();
|
||||
expect(updateUnit).not.toHaveBeenCalled();
|
||||
});
|
||||
test("addMissingUnitAsAlias ignores case when checking for the alias", async () => {
|
||||
const wrapped = wrapper();
|
||||
const { addMissingUnitAsAlias, setCurrentUnit, setCurrentIng } = wrapped.vm;
|
||||
setCurrentIng({
|
||||
ingredient: {
|
||||
unit: { name: "2uwunit", id: "unit_id_2", aliases: [{ name: "uwunit" }] },
|
||||
},
|
||||
});
|
||||
setCurrentUnit("UwUnit");
|
||||
await addMissingUnitAsAlias();
|
||||
expect(updateUnit).not.toHaveBeenCalled();
|
||||
});
|
||||
test("addMissingUnitAsAlias fails gracefully", async () => {
|
||||
updateUnit.mockResolvedValue(undefined);
|
||||
const wrapped = wrapper();
|
||||
@@ -644,6 +656,18 @@ describe("useParseIngredientsDialog", () => {
|
||||
await addMissingFoodAsAlias();
|
||||
expect(updateFood).not.toHaveBeenCalled();
|
||||
});
|
||||
test("addMissingFoodAsAlias ignores case when checking for the alias", async () => {
|
||||
const wrapped = wrapper();
|
||||
const { addMissingFoodAsAlias, setCurrentFood, setCurrentIng } = wrapped.vm;
|
||||
setCurrentIng({
|
||||
ingredient: {
|
||||
food: { name: "f2uwud", id: "food_id_2", aliases: [{ name: "fuwud" }] },
|
||||
},
|
||||
});
|
||||
setCurrentFood("FuWud");
|
||||
await addMissingFoodAsAlias();
|
||||
expect(updateFood).not.toHaveBeenCalled();
|
||||
});
|
||||
test("addMissingFoodAsAlias fails gracefully", async () => {
|
||||
updateFood.mockResolvedValue(undefined);
|
||||
const wrapped = wrapper();
|
||||
|
||||
@@ -338,7 +338,8 @@ export function useParseIngredientsDialog(
|
||||
}
|
||||
|
||||
unit.aliases = unit.aliases || [];
|
||||
if (unit.aliases.map(a => a.name).includes(currentMissingUnit.value)) {
|
||||
const missingUnit = currentMissingUnit.value.toLowerCase();
|
||||
if (unit.aliases.some(a => a.name.toLowerCase() === missingUnit)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -367,7 +368,8 @@ export function useParseIngredientsDialog(
|
||||
}
|
||||
|
||||
food.aliases = food.aliases || [];
|
||||
if (food.aliases.map(a => a.name).includes(currentMissingFood.value)) {
|
||||
const missingFood = currentMissingFood.value.toLowerCase();
|
||||
if (food.aliases.some(a => a.name.toLowerCase() === missingFood)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user