import { render } from '@testing-library/react'; import { Media } from '../Media'; import { BreakpointsContext } from '../BreakpointsContext'; import { BreakpointsProps } from '../breakpoints'; describe('Media', () => { const propsMock = jest.fn(); beforeEach(() => { propsMock.mockClear(); propsMock.mockImplementation((props: BreakpointsProps) => { return props; }); }); type Breakpoints = 'sm' | 'md' | 'lg'; const breakpointsProps: BreakpointsProps = { breakpoints: { sm: 1, md: 2, lg: 3 }, currentBreakpoint: 'md', }; function TestComponent() { return ( {props => { propsMock(props); return
; }} ); } it('passed the context props its child render function as arguments', () => { render( , ); expect(propsMock.mock.results).toMatchObject([ { type: 'return', value: breakpointsProps, }, ]); }); });