From 80d6c284c0f03c3fe1b7367ed58193bd948dcd7e Mon Sep 17 00:00:00 2001 From: Pranay Kothapalli Date: Wed, 24 Jun 2026 10:47:23 +0530 Subject: [PATCH] test(Tooltip): lazy mount tooltip content (#1847) --- .../Tooltip/tests/Tooltip.lazyMount.test.tsx | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/components/ui/Tooltip/tests/Tooltip.lazyMount.test.tsx diff --git a/src/components/ui/Tooltip/tests/Tooltip.lazyMount.test.tsx b/src/components/ui/Tooltip/tests/Tooltip.lazyMount.test.tsx new file mode 100644 index 000000000..680b0c9ae --- /dev/null +++ b/src/components/ui/Tooltip/tests/Tooltip.lazyMount.test.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import Tooltip from '../Tooltip'; + +describe('Tooltip lazy mount', () => { + test('does not mount tooltip content until opened', () => { + render( + + Hover me + Tooltip label + + ); + + expect(screen.queryByTestId('tooltip-content')).not.toBeInTheDocument(); + }); + + test('mounts content after hover opens the tooltip', async() => { + const user = userEvent.setup(); + + render( + + Hover me + Tooltip label + + ); + + await user.hover(screen.getByText('Hover me')); + expect(screen.getByText('Tooltip label')).toBeInTheDocument(); + }); +});