import React, { HtmlHTMLAttributes } from 'react'; import { baselineComponent } from '../../testing/utils'; import { render, screen } from '@testing-library/react'; import Tooltip from './Tooltip'; import View from '../View/View'; import Panel from '../Panel/Panel'; import { HasRootRef } from '../../types'; const Wrapper = ({ children }: any) => ( {children} ); describe('Tooltip', () => { baselineComponent((props) => (
), { forward: false, }); describe('preserves child ref', () => { it('on DOM child', () => { const ref = jest.fn(); render((
)); expect(ref).toHaveBeenCalledWith(screen.getByTestId('xxx')); }); it('on VKUI child', () => { const RefNode = ({ getRootRef, ...props }: HasRootRef & HtmlHTMLAttributes) => (
); const ref = jest.fn(); render(( )); expect(ref).toHaveBeenCalledWith(screen.getByTestId('xxx')); }); }); });