import { ExpensesService } from './expenses.service';

describe('ExpensesService permission-scoped lookups', () => {
  it('returns only minimal room and student fields needed by expense forms', async () => {
    const roomRepo = {
      find: jest.fn().mockResolvedValue([{ id: 1, roomNumber: '101', building: 'A' }]),
    };
    const studentRepo = {
      find: jest.fn().mockResolvedValue([{ id: 2, name: '张三', studentNo: 'S2' }]),
    };
    const service = new ExpensesService(
      {} as never,
      {} as never,
      roomRepo as never,
      studentRepo as never,
    );

    await expect(service.getFormLookups()).resolves.toEqual({
      rooms: [{ id: 1, roomNumber: '101', building: 'A' }],
      students: [{ id: 2, name: '张三', studentNo: 'S2' }],
    });
    expect(roomRepo.find).toHaveBeenCalledWith(expect.objectContaining({ select: ['id', 'roomNumber', 'building'] }));
    expect(studentRepo.find).toHaveBeenCalledWith(expect.objectContaining({ select: ['id', 'name', 'studentNo'] }));
  });
});
