PettyUI/packages/core/tests/utilities/portal.test.tsx
Mats Bosson 7dd8615757 Package entry point and lint fixes
Adds packages/core/src/index.ts as the convenience re-export barrel for
all Dialog parts, Presence, Portal, VisuallyHidden, createFocusTrap,
createScrollLock, and createDismiss. Also resolves pre-existing biome
formatter and noNonNullAssertion violations across five files so CI passes.
2026-03-29 06:01:41 +07:00

28 lines
923 B
TypeScript

import { render } from "@solidjs/testing-library";
import { describe, expect, it } from "vitest";
import { Portal } from "../../src/utilities/portal/portal";
describe("Portal", () => {
it("renders children into document.body by default", () => {
render(() => (
<Portal>
<div data-testid="portal-content">hello</div>
</Portal>
));
// Content should be in document.body, not the render container
expect(document.body.querySelector("[data-testid='portal-content']")).toBeTruthy();
});
it("renders children into a custom target", () => {
const target = document.createElement("div");
document.body.appendChild(target);
render(() => (
<Portal target={target}>
<div data-testid="custom-portal">hello</div>
</Portal>
));
expect(target.querySelector("[data-testid='custom-portal']")).toBeTruthy();
document.body.removeChild(target);
});
});