import React from 'react'; import { render, screen, fireEvent, waitFor } from '@testing-library/react'; import SourceDropdownContainer from './SourceDropdownContainer'; describe('SourceDropdownContainer', () => { it('Render a dropdown container with child component(s)', async () => { const children = Hello world; const { baseElement } = render( {children} , ); const content = baseElement.querySelector(`#dropdown-content`) as HTMLSpanElement; expect(content).toBeTruthy(); }); it('Render collapsed state with single button to re-expand no children', async () => { const children = Hello world; const { baseElement } = render( {children} , ); const content = baseElement.querySelector(`#dropdown-content`) as HTMLSpanElement; expect(content).toBeFalsy(); const expandButton = screen.getByRole('button', { name: /Expand browse options/i }); expect(expandButton).toBeTruthy(); }); it('Will envoke onExpand callback function when expand button is pressed', async () => { const onExpand = jest.fn(); const children = Hello world; render( {children} , ); const expandButton = screen.getByRole('button', { name: /Expand browse options/i }); fireEvent.click(expandButton); expect(onExpand).toHaveBeenCalled(); }); });