import { jsx } from "react/jsx-runtime";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import {
  Types
} from "@makeswift/prop-controllers";
import { randomUUID } from "crypto";
import { Page } from "../../page";
import { act } from "react";
import { ReactRuntime } from "../../../../react";
import * as Testing from "../../../testing";
const pagePropControllerTest = (propDef, value, component, assert, options) => describe("Page", () => {
  test(`can render ${propDef.type} v0 data`, async () => {
    const descriptorV0 = {
      type: propDef.type,
      options
    };
    const TestComponentType = "TestComponent";
    const testId = "test-id";
    const elementData = Testing.createRootComponent([
      {
        key: randomUUID(),
        type: TestComponentType,
        props: {
          propKey: propDef.toPropData(value, descriptorV0)
        }
      }
    ]);
    const snapshot = Testing.createMakeswiftPageSnapshot(elementData);
    const runtime = new ReactRuntime();
    runtime.registerComponent(component(testId), {
      type: TestComponentType,
      label: "TestComponent",
      props: {
        propKey: propDef(options)
      }
    });
    await act(
      async () => render(
        /* @__PURE__ */ jsx(Testing.ReactProvider, { runtime, children: /* @__PURE__ */ jsx(Page, { snapshot }) })
      )
    );
    assert(screen.getByTestId(testId));
  });
  test(`can render ${propDef.type} v1 data`, async () => {
    const gapXDefinitionV1 = {
      type: Types.GapX,
      version: 1,
      options: {}
    };
    const TestComponentType = "TestComponent";
    const testId = "test-id";
    const elementData = Testing.createRootComponent([
      {
        key: randomUUID(),
        type: TestComponentType,
        props: {
          propKey: propDef.toPropData(value, gapXDefinitionV1)
        }
      }
    ]);
    const snapshot = Testing.createMakeswiftPageSnapshot(elementData);
    const runtime = new ReactRuntime();
    runtime.registerComponent(component(testId), {
      type: TestComponentType,
      label: "TestComponent",
      props: {
        propKey: propDef(options)
      }
    });
    await act(
      async () => render(
        /* @__PURE__ */ jsx(Testing.ReactProvider, { runtime, children: /* @__PURE__ */ jsx(Page, { snapshot }) })
      )
    );
    assert(screen.getByTestId(testId));
  });
});
export {
  pagePropControllerTest
};
//# sourceMappingURL=page-prop-controller.js.map