|
10 | 10 | * governing permissions and limitations under the License.
|
11 | 11 | */
|
12 | 12 |
|
13 |
| -import {act, fireEvent, pointerMap, render, triggerPress, within} from '@react-spectrum/test-utils'; |
14 |
| -import {ActionButton, Button} from '@react-spectrum/button'; |
15 |
| -import {ButtonGroup} from '@react-spectrum/buttongroup'; |
16 |
| -import {Content, Header} from '@react-spectrum/view'; |
17 |
| -import {Dialog, DialogContainer, useDialogContainer} from '../src'; |
| 13 | +import {act, fireEvent, render, triggerPress, within} from '@react-spectrum/test-utils'; |
18 | 14 | import {DialogContainerExample, MenuExample, NestedDialogContainerExample} from '../stories/DialogContainerExamples';
|
19 |
| -import {Divider} from '@react-spectrum/divider'; |
20 |
| -import {Heading, Text} from '@react-spectrum/text'; |
21 | 15 | import {Provider} from '@react-spectrum/provider';
|
22 |
| -import React, {useState} from 'react'; |
| 16 | +import React from 'react'; |
23 | 17 | import {theme} from '@react-spectrum/theme-default';
|
24 |
| -import userEvent from '@testing-library/user-event'; |
25 | 18 |
|
26 | 19 | describe('DialogContainer', function () {
|
27 | 20 | beforeAll(() => {
|
@@ -214,57 +207,4 @@ describe('DialogContainer', function () {
|
214 | 207 |
|
215 | 208 | expect(document.activeElement).toBe(button);
|
216 | 209 | });
|
217 |
| - |
218 |
| - describe('portalContainer', () => { |
219 |
| - let user; |
220 |
| - beforeAll(() => { |
221 |
| - user = userEvent.setup({delay: null, pointerMap}); |
222 |
| - jest.useFakeTimers(); |
223 |
| - }); |
224 |
| - function ExampleDialog(props) { |
225 |
| - let container = useDialogContainer(); |
226 |
| - |
227 |
| - return ( |
228 |
| - <Dialog> |
229 |
| - <Heading>The Heading</Heading> |
230 |
| - <Header>The Header</Header> |
231 |
| - <Divider /> |
232 |
| - <Content><Text>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sit amet tristique risus. In sit amet suscipit lorem. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In condimentum imperdiet metus non condimentum. Duis eu velit et quam accumsan tempus at id velit. Duis elementum elementum purus, id tempus mauris posuere a. Nunc vestibulum sapien pellentesque lectus commodo ornare.</Text></Content> |
233 |
| - {!props.isDismissable && |
234 |
| - <ButtonGroup> |
235 |
| - <Button variant="secondary" onPress={container.dismiss}>Cancel</Button> |
236 |
| - <Button variant="cta" onPress={container.dismiss}>Confirm</Button> |
237 |
| - </ButtonGroup> |
238 |
| - } |
239 |
| - </Dialog> |
240 |
| - ); |
241 |
| - } |
242 |
| - function App(props) { |
243 |
| - let [container, setContainer] = useState(); |
244 |
| - let [isOpen, setOpen] = useState(false); |
245 |
| - |
246 |
| - return ( |
247 |
| - <Provider theme={theme}> |
248 |
| - <ActionButton onPress={() => setOpen(true)}>Open dialog</ActionButton> |
249 |
| - <DialogContainer onDismiss={() => setOpen(false)} UNSTABLE_portalContainer={container} {...props}> |
250 |
| - {isOpen && |
251 |
| - <ExampleDialog {...props} /> |
252 |
| - } |
253 |
| - </DialogContainer> |
254 |
| - <div ref={setContainer} data-testid="custom-container" /> |
255 |
| - </Provider> |
256 |
| - ); |
257 |
| - } |
258 |
| - |
259 |
| - it('should render the dialog in the portal container', async () => { |
260 |
| - let {getByRole, getByTestId} = render( |
261 |
| - <App /> |
262 |
| - ); |
263 |
| - |
264 |
| - let button = getByRole('button'); |
265 |
| - await user.click(button); |
266 |
| - |
267 |
| - expect(getByRole('dialog').closest('[data-testid="custom-container"]')).toBe(getByTestId('custom-container')); |
268 |
| - }); |
269 |
| - }); |
270 | 210 | });
|
0 commit comments