// Type declarations for Jest globals
declare const jest: {
  fn: <T extends (...args: any[]) => any>(
    implementation?: T
  ) => jest.Mock<ReturnType<T>, Parameters<T>>;
  mock: (moduleName: string, factory?: any) => void;
  clearAllMocks: () => void;
  requireActual: (moduleName: string) => any;
  spyOn: (
    object: any,
    methodName: string
  ) => {
    mockImplementation: (fn: any) => any;
  };
};

declare namespace jest {
  interface Mock<T = any, Y extends any[] = any[]> {
    (...args: Y): T;
    mockReturnValue: (value: T) => this;
    mockReturnValueOnce: (value: T) => this;
    mockResolvedValue: <U>(value: U) => this;
    mockImplementation: <U extends (...args: any[]) => any>(fn: U) => this;
    mockImplementationOnce: <U extends (...args: any[]) => any>(fn: U) => this;
  }
}

// Jest test globals
declare function describe(name: string, fn: () => void): void;
declare function it(name: string, fn: () => void | Promise<void>): void;
declare function beforeEach(fn: () => void | Promise<void>): void;
declare function afterEach(fn: () => void | Promise<void>): void;
declare function expect(actual: any): {
  toBe: (expected: any) => void;
  toEqual: (expected: any) => void;
  toHaveBeenCalled: () => void;
  toHaveBeenCalledWith: (...args: any[]) => void;
  toHaveBeenCalledTimes: (count: number) => void;
  toBeGreaterThan: (n: number) => void;
  toHaveProperty: (property: string) => void;
  rejects: {
    toThrow: (expected?: any) => Promise<void>;
  };
  not: {
    toBeNull: () => void;
  };
};
