import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import SidePanel from '../SidePanel'; import SidePanelContext from '../SidePanelContext'; describe('SidePanel', () => { it('should should render nothing', () => { const setPropsFn = jest.fn(); const result = render(, { wrapper: ({ children }) => ( {} }}> {children} ), }); expect(result.container).toBeEmptyDOMElement(); }); it('should send props to context', () => { const setPropsFn = jest.fn(); const onExpandFn = jest.fn(); render( test , { wrapper: ({ children }) => ( {} }}> {children} ), }, ); expect(setPropsFn).toBeCalledWith({ isExpanded: true, isInline: true, children: 'test', onExpand: onExpandFn, defaultSize: 500, }); }); it('should close on unmount', () => { const setPropsFn = jest.fn(); const closeFn = jest.fn(); const result = render(test, { wrapper: ({ children }) => ( {children} ), }); // unmount SidePanel result.rerender(null); expect(closeFn).toBeCalledTimes(1); }); });