import React from "react"; import { render } from "@testing-library/react-native"; import { GeneralContentScreenHookAdapter } from "../GeneralContentScreenHookAdapter"; import { log_error } from "../hookAdapter/logger"; const mockScreenSpy = jest.fn(); jest.mock("../GeneralContentScreen", () => ({ GeneralContentScreen: (props) => { const React = require("react"); const { View } = require("react-native"); mockScreenSpy(props); return ; }, })); jest.mock("../hookAdapter/runInBackground", () => ({ runInBackground: jest.fn(), })); jest.mock("../hookAdapter/logger", () => ({ log_debug: jest.fn(), log_error: jest.fn(), log_info: jest.fn(), })); const { Component } = GeneralContentScreenHookAdapter; describe("GeneralContentScreenHookAdapter", () => { beforeEach(() => { jest.clearAllMocks(); }); it("renders GeneralContentScreen with the hook plugin screen id", () => { const { getByTestId } = render( ); expect(getByTestId("general-content-screen")).toBeDefined(); expect(mockScreenSpy).toHaveBeenCalledWith( expect.objectContaining({ screenId: "screen-1", isScreenWrappedInContainer: false, }) ); }); it("renders nothing and logs an error when hookPlugin is missing", () => { const { toJSON } = render(); expect(toJSON()).toBeNull(); expect(mockScreenSpy).not.toHaveBeenCalled(); expect(log_error).toHaveBeenCalled(); }); it("renders nothing when hookPlugin has no screen_id", () => { const { toJSON } = render(); expect(toJSON()).toBeNull(); }); });