import { vi } from 'vitest';

export class MockIntersectionObserver {
  public readonly root: Element | Document | null;
  public readonly rootMargin: string;
  public readonly thresholds: ReadonlyArray<number>;
  observe: (target: HTMLElement) => void;
  unobserve: (target: HTMLElement) => void;
  disconnect: () => void;

  // @ts-ignore
  constructor(callback: IntersectionObserverCallback, options?: IntersectionObserverInit) {
    this.root = null;
    this.rootMargin = '0px';
    this.thresholds = [1];
    this.observe = vi.fn();
    this.unobserve = vi.fn();
    this.disconnect = vi.fn();
  }

  takeRecords(): IntersectionObserverEntry[] {
    return [];
  }
}
