Skip to content

Commit

Permalink
Cast portal children in ReactWrapper in findInPortal utility
Browse files Browse the repository at this point in the history
  • Loading branch information
ggdouglas committed Jan 12, 2025
1 parent c754125 commit be4509e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/core/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { ReactWrapper } from "enzyme";

import { Portal } from "../src";
import { Portal, type PortalProps } from "../src";

export function findInPortal<P>(overlay: ReactWrapper<P>, selector: string) {
// React 16: createPortal preserves React tree so simple find works.
Expand All @@ -27,7 +27,9 @@ export function findInPortal<P>(overlay: ReactWrapper<P>, selector: string) {

// React 15: unstable_renderSubtree does not preserve tree so we must create new wrapper.
const portal = overlay.find(Portal).instance();
const portalChildren = new ReactWrapper(portal.props.children as React.JSX.Element[]);
const portalChildren = new ReactWrapper(
(portal as React.Component<PortalProps>).props.children as React.JSX.Element[],
);
if (portalChildren.is(selector)) {
return portalChildren;
}
Expand Down

0 comments on commit be4509e

Please sign in to comment.