Files
pepperplus-ui/test/pages/visProgPage/visualProgrammingUI/components/NodeComponents.test.tsx
2026-01-13 11:29:45 +00:00

40 lines
1.3 KiB
TypeScript

import { fireEvent, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import {Tooltip} from "../../../../../src/pages/VisProgPage/visualProgrammingUI/components/NodeComponents.tsx";
import {renderWithSidebar} from "../../../../test-utils/test-utils.tsx";
describe('Tooltip component test', () => {
afterEach(() => {
jest.clearAllMocks();
});
it('renders and shows tooltip content on hover', () => {
renderWithSidebar(
<Tooltip nodeType="phase">
<div>?</div>
</Tooltip>
);
const trigger = screen.getByText('?');
// initially hidden
expect(
screen.queryByText('Phase tooltip text')
).not.toBeInTheDocument();
// hover shows tooltip
fireEvent.mouseOver(trigger);
expect(screen.getByText('phase')).toBeInTheDocument();
expect(
screen.getByText('A phase is a single stage of the program, during a phase Pepper will behave in accordance with any connected norms, goals and triggers')
).toBeInTheDocument();
// rendered via portal
expect(
document.body.contains(
screen.getByText('A phase is a single stage of the program, during a phase Pepper will behave in accordance with any connected norms, goals and triggers')
)
).toBe(true);
});
});