2525 */
2626
2727import 'jest-styled-components'
28- import React from 'react'
28+ import React , { useState } from 'react'
2929import { renderWithTheme } from '@looker/components-test-utils'
3030import {
3131 screen ,
3232 fireEvent ,
3333 waitForElementToBeRemoved ,
3434} from '@testing-library/react'
3535import { SimpleContent } from '../__mocks__/DialogContentSimple'
36+ import { DialogMediumContent } from '../__mocks__/DialogMediumContent'
3637import { Dialog } from './Dialog'
3738import { DialogManager } from './DialogManager'
3839import {
@@ -159,9 +160,6 @@ describe('Dialog', () => {
159160 await waitForElementToBeRemoved ( ( ) => screen . getByText ( 'Dialog content' ) )
160161 } )
161162
162- /**
163- * NOTE: All other tests assume a "uncontrolled" version of Dialog.
164- */
165163 test ( 'Controlled' , async ( ) => {
166164 renderWithTheme ( < Controlled /> )
167165
@@ -176,6 +174,26 @@ describe('Dialog', () => {
176174 await waitForElementToBeRemoved ( ( ) => screen . getByText ( / W e t h e P e o p l e / ) )
177175 } )
178176
177+ test ( 'Controlled no callbacks' , async ( ) => {
178+ const SimpleControlled = ( ) => {
179+ const [ isOpen , setOpen ] = useState ( false )
180+
181+ return (
182+ < >
183+ < Dialog content = { < DialogMediumContent /> } isOpen = { isOpen } />
184+ < button onClick = { ( ) => setOpen ( true ) } > Open Dialog</ button >
185+ </ >
186+ )
187+ }
188+
189+ renderWithTheme ( < SimpleControlled /> )
190+
191+ // Open Dialog
192+ const link = screen . getByText ( 'Open Dialog' )
193+ fireEvent . click ( link )
194+ expect ( screen . queryByText ( / W e t h e P e o p l e / ) ) . toBeInTheDocument ( )
195+ } )
196+
179197 test ( 'Controlled - no children' , async ( ) => {
180198 renderWithTheme ( < ControlledNoChildren /> )
181199
0 commit comments