📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
add: tests for Tooltip
kruzhambus26e79d062cdd
diff --git a/src/ui/__test__/Tooltip.test.tsx b/src/ui/__test__/Tooltip.test.tsxnew file mode 100644index 000000000..c4e94fa0e--- /dev/null+++ b/src/ui/__test__/Tooltip.test.tsx@@ -0,0 +1,43 @@+/* eslint-disable testing-library/prefer-screen-queries */+/* eslint-disable import/no-extraneous-dependencies */+import React from 'react'+import { render, fireEvent } from '@testing-library/react'+import Tooltip from '../Tooltip'++describe('Tooltip', () => {+ it('should render the tooltip text when hovering over the icon', () => {+ const text = 'This is a tooltip'+ const { getByTestId, getByText } = render(+ <Tooltip text={text} />,+ )+ const tooltipIcon = getByTestId('tooltip-icon')+ fireEvent.mouseEnter(tooltipIcon)+ const tooltipText = getByText(text)+ expect(tooltipText).toBeInTheDocument()+ })++ it('should render a custom tooltip icon when provided', () => {+ const CustomIcon = () => <div data-testid='custom-icon' />+ const { getByTestId } = render(+ <Tooltip tooltipNode={<CustomIcon />} text='dds' />,+ )+ const customIcon = getByTestId('custom-icon')+ expect(customIcon).toBeInTheDocument()+ })++ it('should render a custom class name when provided', () => {+ const className = 'custom-class'+ const { getByTestId } = render(+ <Tooltip text='Tooltip' className={className} />,+ )+ const tooltipWrapper = getByTestId('tooltip-wrapper')+ expect(tooltipWrapper).toHaveClass(className)+ })++ it('snapshot', () => {+ const { container } = render(+ <Tooltip text='Tooltip' />,+ )+ expect(container).toMatchSnapshot()+ })+})diff --git a/src/ui/__test__/__snapshots__/Chart.test.tsx.snap b/src/ui/__test__/__snapshots__/Chart.test.tsx.snapindex bab01cccf..17d20281b 100644--- a/src/ui/__test__/__snapshots__/Chart.test.tsx.snap+++ b/src/ui/__test__/__snapshots__/Chart.test.tsx.snap@@ -16,7 +16,7 @@ exports[`Chart component snapshot 1`] = `><defs><clippath- id="bb-8754287941272330-clip"+ id="bb-8491962675112450-clip"><rectheight="226"@@ -24,7 +24,7 @@ exports[`Chart component snapshot 1`] = `/></clippath><clippath- id="bb-8754287941272330-clip-xaxis"+ id="bb-8491962675112450-clip-xaxis"><rectheight="110"@@ -34,7 +34,7 @@ exports[`Chart component snapshot 1`] = `/></clippath><clippath- id="bb-8754287941272330-clip-yaxis"+ id="bb-8491962675112450-clip-yaxis"><rectheight="240"@@ -44,7 +44,7 @@ exports[`Chart component snapshot 1`] = `/></clippath><clippath- id="bb-8754287941272330-clip-grid"+ id="bb-8491962675112450-clip-grid"><rectheight="226"@@ -58,7 +58,7 @@ exports[`Chart component snapshot 1`] = `><gclass="bb-grid"- clip-path="url(http://localhost/#bb-8754287941272330-clip-grid)"+ clip-path="url(http://localhost/#bb-8491962675112450-clip-grid)"><gclass="bb-xgrid-focus"@@ -74,7 +74,7 @@ exports[`Chart component snapshot 1`] = `</g><gclass="bb-chart"- clip-path="url(http://localhost/#bb-8754287941272330-clip)"+ clip-path="url(http://localhost/#bb-8491962675112450-clip)"><gclass="bb-event-rects bb-event-rects-single"@@ -215,7 +215,7 @@ exports[`Chart component snapshot 1`] = `</g><gclass="bb-axis bb-axis-x"- clip-path="url(http://localhost/#bb-8754287941272330-clip-xaxis)"+ clip-path="url(http://localhost/#bb-8491962675112450-clip-xaxis)"transform="translate(0, 226)"><text@@ -370,7 +370,7 @@ exports[`Chart component snapshot 1`] = `</g><gclass="bb-axis bb-axis-y"- clip-path="url(http://localhost/#bb-8754287941272330-clip-yaxis)"+ clip-path="url(http://localhost/#bb-8491962675112450-clip-yaxis)"transform="translate(0, 0)"><textdiff --git a/src/ui/__test__/__snapshots__/Tooltip.test.tsx.snap b/src/ui/__test__/__snapshots__/Tooltip.test.tsx.snapnew file mode 100644index 000000000..b478c9d2a--- /dev/null+++ b/src/ui/__test__/__snapshots__/Tooltip.test.tsx.snap@@ -0,0 +1,37 @@+// Jest Snapshot v1, https://goo.gl/fbAQLP++exports[`Tooltip snapshot 1`] = `+<div>+ <div+ class="w-5 h-5 relative flex flex-col group items-center"+ data-testid="tooltip-wrapper"+ >+ <svg+ aria-hidden="true"+ class="w-5 h-5 text-gray-700 dark:text-gray-300"+ data-testid="tooltip-icon"+ fill="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ clip-rule="evenodd"+ d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm11.378-3.917c-.89-.777-2.366-.777-3.255 0a.75.75 0 01-.988-1.129c1.454-1.272 3.776-1.272 5.23 0 1.513 1.324 1.513 3.518 0 4.842a3.75 3.75 0 01-.837.552c-.676.328-1.028.774-1.028 1.152v.75a.75.75 0 01-1.5 0v-.75c0-1.279 1.06-2.107 1.875-2.502.182-.088.351-.199.503-.331.83-.727.83-1.857 0-2.584zM12 18a.75.75 0 100-1.5.75.75 0 000 1.5z"+ fill-rule="evenodd"+ />+ </svg>+ <div+ class="absolute bottom-0 flex-col mb-6 hidden group-hover:flex items-center"+ >+ <span+ class="opacity-95 relative w-60 z-10 p-2 text-xs leading-none text-white whitespace-no-wrap bg-gray-700 shadow-lg rounded-md"+ >+ Tooltip+ </span>+ <div+ class="w-3 h-3 -mt-2 rotate-45 bg-gray-700 opacity-95"+ />+ </div>+ </div>+</div>+`;