import React from "react";
import { Text } from "react-native";
import { render } from "@testing-library/react-native";
import { withFocusableContext } from "../withFocusableContext";
import { FocusableGroupContext } from "../FocusableGroupContext";

const MockComponent = ({ groupId }: { groupId: string }) => (
  <Text testID={groupId} />
);

const WrappedComponent = withFocusableContext(MockComponent);

describe("withFocusableContext HOC", () => {
  it("should provide focusable context to the wrapped component", () => {
    const { getByTestId } = render(<WrappedComponent />, {
      // eslint-disable-next-line react/display-name
      wrapper: ({ children }: { children: React.ReactElement }) => (
        <FocusableGroupContext.Provider value="test">
          {children}
        </FocusableGroupContext.Provider>
      ),
    });

    expect(getByTestId("test")).toBeTruthy();
  });
});
