import { renderHook } from "@testing-library/react-hooks";

jest.mock(
  "@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration",
  () => ({
    useScreenConfiguration: jest.fn(),
  })
);

const {
  useScreenConfiguration,
} = require("@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration");

const { useScreenBackgroundColor } = require("../useScreenBackgroundColor");

describe("useScreenBackgroundColor", () => {
  afterEach(() => {
    jest.clearAllMocks();
  });

  it("should return the background color from screen configuration", () => {
    useScreenConfiguration.mockReturnValue({
      backgroundColor: "#FF0000",
    });

    // Render the hook with a screen ID
    const { result } = renderHook(() =>
      useScreenBackgroundColor("test-screen-id")
    );

    expect(result.current).toBe("#FF0000");

    expect(useScreenConfiguration).toHaveBeenCalledWith("test-screen-id");
  });

  it("should return 'transparent' when background color is empty", () => {
    useScreenConfiguration.mockReturnValue({
      backgroundColor: "",
    });

    const { result } = renderHook(() =>
      useScreenBackgroundColor("test-screen-id")
    );

    expect(result.current).toBe("transparent");
  });

  it("should return 'transparent' when background color is null", () => {
    useScreenConfiguration.mockReturnValue({
      backgroundColor: null,
    });

    const { result } = renderHook(() =>
      useScreenBackgroundColor("test-screen-id")
    );

    expect(result.current).toBe("transparent");
  });

  it("should return 'transparent' when background color is undefined", () => {
    useScreenConfiguration.mockReturnValue({});

    const { result } = renderHook(() =>
      useScreenBackgroundColor("test-screen-id")
    );

    expect(result.current).toBe("transparent");
  });
});
