Cleanup after initial plan
This commit is contained in:
parent
d2a7e652b3
commit
245520fb50
53 changed files with 6733 additions and 621 deletions
68
packages/web/src/services/meal-plans.test.ts
Normal file
68
packages/web/src/services/meal-plans.test.ts
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { apiClient } from './api-client';
|
||||
import * as MealPlansService from './meal-plans';
|
||||
|
||||
vi.mock('./api-client', () => ({
|
||||
apiClient: {
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
patch: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
describe('meal-plans service', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('listMealPlans with and without query', async () => {
|
||||
await MealPlansService.listMealPlans('hh1');
|
||||
expect(apiClient.get).toHaveBeenCalledWith('/households/hh1/meal-plans');
|
||||
|
||||
await MealPlansService.listMealPlans('hh1', { cursor: 'cur', limit: 10 });
|
||||
expect(apiClient.get).toHaveBeenCalledWith('/households/hh1/meal-plans?cursor=cur&limit=10');
|
||||
});
|
||||
|
||||
it('getMealPlanByWeek', async () => {
|
||||
await MealPlansService.getMealPlanByWeek('hh1', '2026-05-10');
|
||||
expect(apiClient.get).toHaveBeenCalledWith('/households/hh1/meal-plans/week/2026-05-10');
|
||||
});
|
||||
|
||||
it('getMealPlan', async () => {
|
||||
await MealPlansService.getMealPlan('hh1', 'mp1');
|
||||
expect(apiClient.get).toHaveBeenCalledWith('/households/hh1/meal-plans/mp1');
|
||||
});
|
||||
|
||||
it('createMealPlan', async () => {
|
||||
const data = { weekStartDate: '2026-05-10' } as any;
|
||||
await MealPlansService.createMealPlan('hh1', data);
|
||||
expect(apiClient.post).toHaveBeenCalledWith('/households/hh1/meal-plans', data);
|
||||
});
|
||||
|
||||
it('updateMealPlan', async () => {
|
||||
const data = { days: [] } as any;
|
||||
await MealPlansService.updateMealPlan('hh1', 'mp1', data);
|
||||
expect(apiClient.patch).toHaveBeenCalledWith('/households/hh1/meal-plans/mp1', data);
|
||||
});
|
||||
|
||||
it('updateMealPlanStatus', async () => {
|
||||
await MealPlansService.updateMealPlanStatus('hh1', 'mp1', 'active' as any);
|
||||
expect(apiClient.patch).toHaveBeenCalledWith('/households/hh1/meal-plans/mp1/status', { status: 'active' });
|
||||
});
|
||||
|
||||
it('deleteMealPlan', async () => {
|
||||
await MealPlansService.deleteMealPlan('hh1', 'mp1');
|
||||
expect(apiClient.delete).toHaveBeenCalledWith('/households/hh1/meal-plans/mp1');
|
||||
});
|
||||
|
||||
it('getSuggestions', async () => {
|
||||
await MealPlansService.getSuggestions('hh1', 3);
|
||||
expect(apiClient.get).toHaveBeenCalledWith('/households/hh1/meal-plans/suggestions?limit=3');
|
||||
});
|
||||
|
||||
it('getShoppingGap', async () => {
|
||||
await MealPlansService.getShoppingGap('hh1', 'mp1');
|
||||
expect(apiClient.get).toHaveBeenCalledWith('/households/hh1/meal-plans/mp1/gap');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue