Tests refactor

This commit is contained in:
Aerilyn Weber 2026-05-19 11:06:03 +09:00
parent 245520fb50
commit 99134d8556
165 changed files with 911 additions and 531 deletions

View file

@ -8,7 +8,7 @@ import type {
NutritionInfo,
MealPlanDaySchema,
} from '@meshitrack/shared';
import { z } from 'zod/v4';
import { type z } from 'zod/v4';
type MealPlanDay = z.infer<typeof MealPlanDaySchema>;
@ -39,19 +39,12 @@ export class MealPlanService {
return this.mealPlanRepository.findByWeek(householdId, weekStartDate);
}
public async create(
householdId: string,
createdBy: string,
input: CreateMealPlanInput
) {
public async create(householdId: string, createdBy: string, input: CreateMealPlanInput) {
// Prevent overlapping meal plans for same household/week
const existing = await this.mealPlanRepository.findByWeek(
householdId,
input.weekStartDate
);
const existing = await this.mealPlanRepository.findByWeek(householdId, input.weekStartDate);
if (existing) {
throw new BadRequestError(
`A meal plan already exists for household ${householdId} starting ${input.weekStartDate}`
`A meal plan already exists for household ${householdId} starting ${input.weekStartDate}`,
);
}
@ -66,11 +59,7 @@ export class MealPlanService {
});
}
public async update(
id: string,
householdId: string,
input: UpdateMealPlanInput
) {
public async update(id: string, householdId: string, input: UpdateMealPlanInput) {
const existing = await this.getById(id, householdId);
const data: Record<string, unknown> = {};
@ -90,11 +79,7 @@ export class MealPlanService {
return updated;
}
public async updateStatus(
id: string,
householdId: string,
status: MealPlanStatus
) {
public async updateStatus(id: string, householdId: string, status: MealPlanStatus) {
await this.getById(id, householdId);
const updated = await this.mealPlanRepository.updateStatus(id, householdId, status);
if (!updated) {