feat(shopping): setCartServings mit Positiv-Validation
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 2m15s
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 2m15s
This commit is contained in:
@@ -4,7 +4,8 @@ import { insertRecipe } from '../../src/lib/server/recipes/repository';
|
||||
import {
|
||||
addRecipeToCart,
|
||||
removeRecipeFromCart,
|
||||
listShoppingList
|
||||
listShoppingList,
|
||||
setCartServings
|
||||
} from '../../src/lib/server/shopping/repository';
|
||||
import type { Recipe } from '../../src/lib/types';
|
||||
|
||||
@@ -84,3 +85,21 @@ describe('removeRecipeFromCart', () => {
|
||||
expect(() => removeRecipeFromCart(db, id)).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('setCartServings', () => {
|
||||
it('updates servings for a cart recipe', () => {
|
||||
const db = openInMemoryForTest();
|
||||
const id = insertRecipe(db, recipe());
|
||||
addRecipeToCart(db, id, null, 4);
|
||||
setCartServings(db, id, 8);
|
||||
expect(listShoppingList(db).recipes[0].servings).toBe(8);
|
||||
});
|
||||
|
||||
it('rejects non-positive servings', () => {
|
||||
const db = openInMemoryForTest();
|
||||
const id = insertRecipe(db, recipe());
|
||||
addRecipeToCart(db, id, null, 4);
|
||||
expect(() => setCartServings(db, id, 0)).toThrow();
|
||||
expect(() => setCartServings(db, id, -3)).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user