// Mock the isIos function directly
jest.mock('@components/Modals/components/BottomSheet/utils', () => {
  const originalModule = jest.requireActual(
    '@components/Modals/components/BottomSheet/utils',
  );
  const {windowDimensions} = jest.requireActual('@shared/constants');

  const getRatioFromSnapPoint = (percentage: string) =>
    parseInt(percentage.replace(/\D/g, ''), 10) / 100;

  const getSnapPointValue = (snapPoint: string | number) =>
    typeof snapPoint === 'number'
      ? snapPoint
      : windowDimensions.height * getRatioFromSnapPoint(snapPoint);

  return {
    ...originalModule,
    getMaxSnapPoint: (snapPoints: any) => {
      const snaps = 'value' in snapPoints! ? snapPoints.value : snapPoints;
      const lastSnapPointValue = getSnapPointValue(snaps![snaps!.length - 1]);
      const firstSnapPointValue = getSnapPointValue(snaps![0]);
      // Force Android behavior (return average)
      return (lastSnapPointValue + firstSnapPointValue) / 2;
    },
  };
});

import {getMaxSnapPoint} from '@components/Modals/components/BottomSheet/utils';

import {
  NUMERIC_PROM,
  NUMERIC_RATIO_SNAP_POINTS,
  NUMERIC_SNAP_POINTS,
  NUMERIC_WINDOW_HEIGHT_PROM,
  RATIO_NUMERIC_SNAP_POINTS,
  RATIO_SNAP_POINTS,
  WINDOW_HEIGHT_NUMERIC_PROM,
  WINDOW_HEIGHT_PROM,
} from './constants';

jest.mock('@shared/utils', () => ({
  isIos: false,
  isAndroid: true,
}));

describe('getMaxSnapPoint isAndroid', () => {
  test.each([
    ['Numeric', NUMERIC_SNAP_POINTS, NUMERIC_PROM],
    ['Ratio', RATIO_SNAP_POINTS, WINDOW_HEIGHT_PROM],
    [
      'Numeric and Ratio',
      NUMERIC_RATIO_SNAP_POINTS,
      NUMERIC_WINDOW_HEIGHT_PROM,
    ],
    [
      'Ratio and Numeric',
      RATIO_NUMERIC_SNAP_POINTS,
      WINDOW_HEIGHT_NUMERIC_PROM,
    ],
  ])(
    'returns last value from %s snap points',
    (_desc, snapPoints, expectedReturnValue) => {
      expect(getMaxSnapPoint(snapPoints)).toBe(expectedReturnValue);
    },
  );
});
