Cleanup after initial plan
This commit is contained in:
parent
d2a7e652b3
commit
245520fb50
53 changed files with 6733 additions and 621 deletions
|
|
@ -243,4 +243,88 @@ describe('meal-plan.routes', () => {
|
|||
expect(Array.isArray(body.missingItems)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /api/v1/households/:householdId/meal-plans/:id', () => {
|
||||
it('returns plan if found', async () => {
|
||||
const planWithMeal = makePlan({
|
||||
createdAt: new Date(),
|
||||
days: [{
|
||||
date: '2026-05-10',
|
||||
meals: [{
|
||||
id: '123e4567-e89b-42d3-a456-426614174000',
|
||||
type: 'dinner',
|
||||
recipeId: 'recipe-1',
|
||||
recipeName: 'Spaghetti',
|
||||
servings: 2,
|
||||
perServingNutrition: emptyNutrition,
|
||||
customName: 'My Pasta',
|
||||
customNutrition: emptyNutrition,
|
||||
notes: 'Very yummy',
|
||||
}],
|
||||
dailyNutritionTotal: emptyNutrition,
|
||||
}]
|
||||
});
|
||||
mockFindById.mockResolvedValue(planWithMeal);
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/api/v1/households/hh1/meal-plans/plan-1',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.json()._id).toBe('plan-1');
|
||||
expect(res.json().days[0].meals).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('PATCH /api/v1/households/:householdId/meal-plans/:id', () => {
|
||||
it('updates plan content and returns it', async () => {
|
||||
mockUpdate.mockResolvedValue(makePlan({ status: MealPlanStatus.ACTIVE }));
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'PATCH',
|
||||
url: '/api/v1/households/hh1/meal-plans/plan-1',
|
||||
headers: { ...authHeaders, 'content-type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
status: MealPlanStatus.ACTIVE,
|
||||
}),
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.json().status).toBe(MealPlanStatus.ACTIVE);
|
||||
});
|
||||
});
|
||||
|
||||
describe('PATCH /api/v1/households/:householdId/meal-plans/:id/status', () => {
|
||||
it('updates plan status directly and returns it', async () => {
|
||||
mockUpdateStatus.mockResolvedValue(makePlan({ status: MealPlanStatus.ACTIVE }));
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'PATCH',
|
||||
url: '/api/v1/households/hh1/meal-plans/plan-1/status',
|
||||
headers: { ...authHeaders, 'content-type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
status: MealPlanStatus.ACTIVE,
|
||||
}),
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.json().status).toBe(MealPlanStatus.ACTIVE);
|
||||
});
|
||||
});
|
||||
|
||||
describe('DELETE /api/v1/households/:householdId/meal-plans/:id', () => {
|
||||
it('deletes the plan and returns 204', async () => {
|
||||
mockDelete.mockResolvedValue(makePlan());
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'DELETE',
|
||||
url: '/api/v1/households/hh1/meal-plans/plan-1',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(204);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue