| 272 | ); |
| 273 | } |
| 274 | function App() { |
| 275 | let container = useRef(null); |
| 276 | return ( |
| 277 | <> |
| 278 | <UNSAFE_PortalProvider getContainer={() => container.current}> |
| 279 | <InfoPopover container={container} /> |
| 280 | </UNSAFE_PortalProvider> |
| 281 | <div ref={container} data-testid="custom-container" /> |
| 282 | </> |
| 283 | ); |
| 284 | } |
| 285 | it('should render the dialog in the portal container set by the PortalProvider', async () => { |
| 286 | let {getByRole, getByTestId} = render(<App />); |
| 287 | |
| 288 | let button = getByRole('button'); |
| 289 | await user.click(button); |
| 290 | |
| 291 | expect(getByRole('dialog').closest('[data-testid="custom-container"]')).toBe( |
| 292 | getByTestId('custom-container') |
| 293 | ); |
| 294 | }); |
| 295 | }); |
| 296 | |
| 297 | // TODO: delete this test when we get rid of the deprecated prop |
| 298 | describe('portalContainer', () => { |