fix(shopping): omit units for ingredients without quantities
This commit is contained in:
1 parent
8fa63415f1
commit
9ecd36db0f
3 files changed
+10
-2
No files matched your search
@@ -7,7 +7,7 @@ Stand: **24. Oktober 2026**. Die folgenden Prüfungen wurden tatsächlich ausgef
|
||||
| Prüfung | Ergebnis |
|
||||
| ---------------------- | ------------------------------------------------------------------ |
|
||||
| `npm run typecheck` | Erfolgreich, keine TypeScript-Fehler |
|
||||
| `npm test` | **33/33 Tests bestanden**, 3 Testdateien |
|
||||
| `npm test` | **34/34 Tests bestanden**, 3 Testdateien |
|
||||
| `npm run build` | Erfolgreicher Next.js-Produktionsbuild, keine Buildwarnungen |
|
||||
| `npm run test:e2e` | **17/17 Tests bestanden**, keine Retries oder übersprungenen Tests |
|
||||
| `npm audit --omit=dev` | **0 gemeldete Schwachstellen** zum Prüfzeitpunkt |
|
||||
|
||||
@@ -73,7 +73,7 @@ export function mergeShopping(existing: ShoppingItem[], ingredients: Ingredient[
|
||||
for (const i of ingredients) {
|
||||
const amount = scaledAmount(i, factor);
|
||||
const dimension = dimensions[i.unit];
|
||||
const unit = dimension ? (dimension[0] === 'mass' ? 'g' : 'ml') : i.unit;
|
||||
const unit = amount === null ? '' : dimension ? (dimension[0] === 'mass' ? 'g' : 'ml') : i.unit;
|
||||
const normalized = amount === null ? null : convert(amount, i.unit, unit);
|
||||
const same = items.find(
|
||||
(x) =>
|
||||
|
||||
@@ -93,4 +93,12 @@ describe('Precise scaling from immutable originals', () => {
|
||||
);
|
||||
expect(b).toHaveLength(3);
|
||||
});
|
||||
it('does not display an artificial unit for unquantified shopping ingredients', () => {
|
||||
const list = mergeShopping(
|
||||
[],
|
||||
[{ ...chicken, name: 'Salz', amount: null, note: 'nach Geschmack' }],
|
||||
'4',
|
||||
);
|
||||
expect(list[0]).toMatchObject({ amount: null, unit: '', note: 'nach Geschmack' });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user