import { describe, expect, it } from 'vitest';
import {
  toStaffAttendanceRecordViewModel,
  toStaffAttendanceSummaryViewModel,
} from '@/business/staff-attendance/mappers';
import type {
  StaffAttendanceRecordDto,
  StaffAttendanceSummaryDto,
} from '@/shared/types/staffAttendance';

describe('staff attendance mappers', () => {
  it('maps backend record DTO fields into the frontend view model shape', () => {
    const dto: StaffAttendanceRecordDto = {
      id: 'record-1',
      date: '2026-06-08',
      status: 'late',
      note: 'Traffic delay',
      user_name: 'Jordan Lee',
      user_role: 'Teacher',
      organizationId: 'org-1',
      campusId: 'campus-1',
      userId: 'user-1',
      createdAt: '2026-06-08T08:00:00.000Z',
      updatedAt: '2026-06-08T08:15:00.000Z',
    };

    expect(toStaffAttendanceRecordViewModel(dto)).toEqual({
      id: 'record-1',
      date: '2026-06-08',
      status: 'late',
      note: 'Traffic delay',
      userName: 'Jordan Lee',
      userRole: 'Teacher',
    });
  });

  it('maps backend summary DTO fields into the frontend view model shape', () => {
    const dto: StaffAttendanceSummaryDto = {
      staffCount: 24,
      recordsCount: 23,
      present: 20,
      late: 2,
      absent: 1,
    };

    expect(toStaffAttendanceSummaryViewModel(dto)).toEqual({
      staffCount: 24,
      recordsCount: 23,
      present: 20,
      late: 2,
      absent: 1,
    });
  });
});
