import * as React from 'react' ; import '@testing-library/jest-dom' ; import { renderWithProviders } from '@opentrons/components' ; import { i18n } from '../../../i18n' ; import { CollapsibleStep } from '../RunSetupCard/CollapsibleStep' ; import { fireEvent } from '@testing-library/react' ; describe ( 'CollapsibleStep' , ( ) => { const render = ( { expanded = true , title = 'stub title' , description = 'stub description' , label = 'stub label' , rightAlignedNode = null , toggleExpanded = toggleExpandedMock , children = < button > stub children < / button > , } = { } ) => { return renderWithProviders ( < CollapsibleStep { ... { expanded , title , description , label , toggleExpanded , children , rightAlignedNode , } } / > , { i18nInstance : i18n } ) [ 0 ] ; } ; let toggleExpandedMock ; beforeEach ( ( ) => { toggleExpandedMock = jest . fn ( ) ; } ) ; afterEach ( ( ) => { jest . resetAllMocks ( ) ; } ) ; it ( 'renders children' , ( ) => { const { getByRole } = render ( ) ; expect ( getByRole ( 'button' , { name : 'stub children' } ) ) . toBeTruthy ( ) ; } ) ; it ( 'calls toggle expanded on click' , ( ) => { const { getByRole } = render ( { expanded : false } ) ; fireEvent . click ( getByRole ( 'heading' , { name : 'stub title' } ) ) ; expect ( toggleExpandedMock ) . toHaveBeenCalled ( ) ; } ) ; it ( 'renders text nodes with prop contents' , ( ) => { const { getByRole , queryAllByText } = render ( { expanded : false } ) ; expect ( getByRole ( 'heading' , { name : 'stub label' } ) ) . toBeTruthy ( ) ; expect ( getByRole ( 'heading' , { name : 'stub title' } ) ) . toBeTruthy ( ) ; expect ( queryAllByText ( 'stub description' ) ) . toBeTruthy ( ) ; } ) ; } ) ;