| 956 | } |
| 957 | |
| 958 | function App() { |
| 959 | let container = React.useRef(null); |
| 960 | return ( |
| 961 | <> |
| 962 | <InfoMenu container={container} /> |
| 963 | <div ref={container} data-testid="custom-container" /> |
| 964 | </> |
| 965 | ); |
| 966 | } |
| 967 | |
| 968 | it('should render the menu in the portal container', async () => { |
| 969 | tree = render(<App />); |
| 970 | |
| 971 | let button = tree.getByRole('button'); |
| 972 | await user.click(button); |
| 973 | |
| 974 | expect(tree.getByRole('menu').closest('[data-testid="custom-container"]')).toBe( |
| 975 | tree.getByTestId('custom-container') |
| 976 | ); |
| 977 | await user.keyboard('{Escape}'); |
| 978 | act(() => { |
| 979 | jest.runAllTimers(); |
| 980 | }); |
| 981 | }); |
| 982 | |
| 983 | it('should render the menu tray in the portal container', async () => { |
| 984 | windowSpy.mockImplementation(() => 700); |
| 985 | tree = render(<App />); |
| 986 | |
| 987 | let button = tree.getByRole('button'); |
| 988 | await user.click(button); |
| 989 | |
| 990 | expect(tree.getByRole('menu').closest('[data-testid="custom-container"]')).toBe( |
| 991 | tree.getByTestId('custom-container') |
| 992 | ); |
| 993 | }); |
| 994 | }); |
| 995 | |
| 996 | it('does not close if menu is tabbed away from', async function () { |
| 997 | let tree = render( |