import assert from "node:assert/strict"; import test from "node:test"; import { appointmentInput, petInput, prescriptionInput, scheduleAppointmentInput, vaccinationInput, } from "../../src/modules/pets/server/schemas"; const PET_ID = "f5a50e32-a217-4d65-ae10-98a1f441d171"; const CALENDAR_ID = "bd8e10c2-58f4-4db8-9326-0b50fdda47bb"; test("pet and medical record schemas accept bounded valid input", () => { assert.equal(petInput.parse({ name: "Mochi", species: "cat", images: [] }).name, "Mochi"); assert.equal( appointmentInput.parse({ petId: PET_ID, title: "Annual exam", appointmentAt: "2026-08-01T15:00:00.000Z", }).title, "Annual exam", ); assert.equal( vaccinationInput.parse({ petId: PET_ID, name: "Rabies", administeredOn: "2026-07-01" }).name, "Rabies", ); assert.equal( prescriptionInput.parse({ petId: PET_ID, medication: "Apoquel", dosage: "5 mg daily" }).active, true, ); assert.deepEqual( scheduleAppointmentInput.parse({ appointmentId: PET_ID, calendarId: CALENDAR_ID }), { appointmentId: PET_ID, calendarId: CALENDAR_ID, }, ); }); test("pet and medical record schemas reject invalid identifiers, dates, and galleries", () => { assert.throws(() => petInput.parse({ name: "", species: "cat" })); assert.throws(() => petInput.parse({ name: "Mochi", species: "cat", images: Array(11).fill("/api/uploads/pets/a.jpg"), }), ); assert.throws(() => appointmentInput.parse({ petId: "not-a-uuid", title: "Exam", appointmentAt: "not-a-date" }), ); assert.throws(() => vaccinationInput.parse({ petId: PET_ID, name: "Rabies", administeredOn: "07/01/2026" }), ); assert.throws(() => scheduleAppointmentInput.parse({ appointmentId: "bad", calendarId: "also-bad" }), ); });