import { describe, expect, it } from 'vitest';
import { ganttRoomsSchema } from './dashboard';

describe('ganttRoomsSchema 接口校验', () => {
  const validPayload = [
    {
      roomNumber: 'A101',
      occupancies: [
        {
          studentName: '张三',
          studentId: 3,
          checkInDate: '2026-05-01',
          checkOutDate: null,
          billingStartDate: '2026-05-01',
          billingEndDate: null,
        },
      ],
    },
  ];

  it('接受合法的甘特图数据（studentId 为数字）', () => {
    expect(ganttRoomsSchema.safeParse(validPayload).success).toBe(true);
  });

  it('拒绝缺少 checkInDate 的入住记录', () => {
    const payload = [
      {
        roomNumber: 'A101',
        occupancies: [{ studentName: '张三', checkOutDate: null }],
      },
    ];
    expect(ganttRoomsSchema.safeParse(payload).success).toBe(false);
  });

  it('拒绝缺少 studentName 的入住记录', () => {
    const payload = [
      {
        roomNumber: 'A101',
        occupancies: [{ checkInDate: '2026-05-01', checkOutDate: null }],
      },
    ];
    expect(ganttRoomsSchema.safeParse(payload).success).toBe(false);
  });
});
