Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

1.2 KB
Raw Blame
import { render, screen } from '@testing-library/react'
import { afterEach, expect, it, vi } from 'vitest'
import NightPauseTooltip from './NightPauseTooltip'

afterEach(() => vi.restoreAllMocks())

it('keeps the full pause description inside the viewport at its lower right edge', () => {
  vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({ width: 240, height: 56 } as DOMRect)
  const label = 'Tagesende von Tag 12 um 18:00 Uhr'
  render(<NightPauseTooltip label={label} x={window.innerWidth - 5} y={window.innerHeight - 5} />)
  const tooltip = screen.getByRole('tooltip')
  expect(tooltip).toHaveTextContent(label)
  expect(parseFloat(tooltip.style.left) + 240).toBeLessThanOrEqual(window.innerWidth - 12)
  expect(parseFloat(tooltip.style.top) + 56).toBeLessThanOrEqual(window.innerHeight - 12)
  expect(tooltip.style.overflowWrap).toBe('anywhere')
})

it('keeps descriptions visible at the upper left edge', () => {
  vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({ width: 240, height: 56 } as DOMRect)
  render(<NightPauseTooltip label="End of day 1 at 18:00" x={-50} y={-50} />)
  expect(screen.getByRole('tooltip')).toHaveStyle({ left: '12px', top: '12px' })
})