/**
 * Credential Rate Limiting Tests
 */

import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { credentialRateLimitPlugin } from './rate-limit-credential';
import type { FastifyInstance } from 'fastify';

describe('credentialRateLimitPlugin', () => {
  let app: FastifyInstance;

  beforeEach(() => {
    // Mock Fastify app
    app = {
      register: vi.fn(),
      addHook: vi.fn(),
    } as any;
  });

  afterEach(() => {
    vi.clearAllMocks();
  });

  it('should register rate limit plugin', async () => {
    await credentialRateLimitPlugin(app);

    expect(app.register).toHaveBeenCalled();
  });

  it('should configure rate limits correctly', async () => {
    await credentialRateLimitPlugin(app);

    // Check that rate limit configuration is applied
    const registerCall = (app.register as any).mock.calls[0];
    expect(registerCall).toBeDefined();
  });
});

