import { OvertimeService } from './overtime.service';

describe('OvertimeService domain writes', () => {
  it('writes overtime records to relation table', async () => {
    const prisma = {
      overtimeRecord: {
        create: jest.fn().mockResolvedValue({ id: 'ot-1' }),
        delete: jest.fn(),
        findMany: jest.fn(),
        update: jest.fn(),
      },
    };
    const service = new OvertimeService(prisma as any);

    await service.create({
      projectId: 'project-1',
      versionId: 'version-1',
      person: 'member-1',
      startTime: '2026-07-08T19:00:00.000Z',
      endTime: '2026-07-08T21:00:00.000Z',
      duration: 2,
      reasonId: 'reason-4',
    });

    expect(prisma.overtimeRecord.create).toHaveBeenCalledWith({
      data: expect.objectContaining({
        projectId: 'project-1',
        versionId: 'version-1',
        userId: 'member-1',
        reason: 'reason-4',
        startAt: new Date('2026-07-08T19:00:00.000Z'),
        endAt: new Date('2026-07-08T21:00:00.000Z'),
        hours: 2,
      }),
    });
  });
});
