import { renderHook } from '@testing-library/react';
import { useCompactDesktopWidth } from '../useCompactDesktopWidth';

describe('useCompactDesktopWidth', () => {
  it('returns unmodified width on mobile', () => {
    const { result } = renderHook(() =>
      useCompactDesktopWidth({ widgetWidth: 1200, contentSize: 2, isMobile: true }),
    );

    expect(result.current).toEqual({ width: 1200, isCompact: false });
  });

  it('clamps oversized desktop widgets with small content', () => {
    const { result } = renderHook(() =>
      useCompactDesktopWidth({ widgetWidth: 1600, contentSize: 2, isMobile: false }),
    );

    expect(result.current).toEqual({ width: 644, isCompact: true });
  });

  it('skips clamping when widget is already narrow', () => {
    const { result } = renderHook(() =>
      useCompactDesktopWidth({ widgetWidth: 620, contentSize: 2, isMobile: false }),
    );

    expect(result.current).toEqual({ width: 620, isCompact: false });
  });

  it('ignores content sizes greater than 3', () => {
    const { result } = renderHook(() =>
      useCompactDesktopWidth({ widgetWidth: 1400, contentSize: 4, isMobile: false }),
    );

    expect(result.current).toEqual({ width: 1400, isCompact: false });
  });
});
