import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { render } from '@testing-library/react';

vi.mock('@tamagui/core', () => ({
  useTheme: () => ({
    primary: { val: '#FF5A5F' },
    borderColor: { val: '#e5e7eb' },
    surface: { val: '#ffffff' },
  }),
}));

vi.mock('@tamagui/stacks', () => ({
  YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
  XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));

vi.mock('@tamagui/text', () => ({
  SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));

vi.mock('@tamagui/react-native-web-lite', () => ({
  Pressable: ({ children }: { children: React.ReactNode }) => <button type="button">{children}</button>,
}));

vi.mock('@tamagui/checkbox', () => ({
  Checkbox: Object.assign(
    ({ children, checked, onCheckedChange, id }: any) => (
      <label>
        <input
          type="checkbox"
          id={id}
          checked={checked}
          onChange={(event) => onCheckedChange?.(event.target.checked)}
        />
        {children}
      </label>
    ),
    { Indicator: ({ children }: { children: React.ReactNode }) => <span>{children}</span> },
  ),
}));

vi.mock('@tamagui/sheet', () => {
  const Sheet = ({ children }: { children: React.ReactNode }) => <div>{children}</div>;
  Sheet.Frame = ({ children }: { children: React.ReactNode }) => <div>{children}</div>;
  Sheet.Overlay = ({ children }: { children?: React.ReactNode }) => <div>{children}</div>;
  Sheet.ScrollView = ({ children }: { children: React.ReactNode }) => <div>{children}</div>;
  Sheet.Handle = () => <div />;
  return { Sheet };
});

import { LegalConsentSheet } from '../LegalConsentSheet';

describe('LegalConsentSheet', () => {
  it('renders the required consent checkboxes when open', () => {
    const { getAllByRole } = render(
      <LegalConsentSheet
        open={true}
        onClose={vi.fn()}
        onConfirm={vi.fn()}
        t={(key: string, fallback?: string) => fallback ?? key}
      />
    );

    expect(getAllByRole('checkbox')).toHaveLength(2);
  });
});
