import { describe, expect, it, vi } from 'vitest';
import { listGuardianStudents } from '@/shared/api/guardianStudents';
import { apiRequest } from '@/shared/api/httpClient';

vi.mock('@/shared/api/httpClient', () => ({
  apiRequest: vi.fn(),
}));

describe('guardian students API', () => {
  it('lists all or student-filtered guardian links', async () => {
    vi.mocked(apiRequest).mockResolvedValue({ rows: [] });

    await listGuardianStudents();
    await listGuardianStudents('student-1');

    expect(apiRequest).toHaveBeenNthCalledWith(1, '/guardian_students');
    expect(apiRequest).toHaveBeenNthCalledWith(2, '/guardian_students?studentId=student-1');
  });
});
