import React from 'react'; import { render, cleanup, fireEvent } from '@testing-library/react'; import { Navigation } from '../src/components/navigation/navigation'; import { carouselItemNodes } from './__fixtures__/nodes'; describe('', () => { afterEach(cleanup); it('should render factory components in correct order', async () => { const onClick = jest.fn(); const items = carouselItemNodes(5); const factory = (selected: boolean) => (
{selected ? 'selected' : 'unselected'}
); const { getByText, getAllByText } = render( , ); expect(getByText('selected')).toBeTruthy(); expect(getAllByText('unselected').length).toEqual(4); }); it('should render call onClick callback for factory components', async () => { const onClick = jest.fn(); const items = carouselItemNodes(5); const factory = (selected: boolean) => (
{selected ? 'selected' : 'unselected'}
); const { getByText } = render( , ); fireEvent.mouseOver(getByText('selected')); expect(onClick).toHaveBeenCalled(); }); });