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.3 KB
Raw Blame
// FE-W4GB-001 to FE-W4GB-004
import { describe, it, expect } from 'vitest'
import { fireEvent } from '@testing-library/react'
import { render, screen } from '../../../tests/helpers/render'
import GuestBadge from './GuestBadge'

describe('GuestBadge', () => {
  it('FE-W4GB-001: renders the translated guest label with the accountless hint as title', () => {
    render(<GuestBadge />)
    const pill = screen.getByTitle(/without an account/i)

    expect(pill).toHaveTextContent('Guest')
    expect(pill.querySelector('svg')).not.toBeNull()
  })

  it('FE-W4GB-002: sizes the label at 10px by default', () => {
    render(<GuestBadge />)
    expect(screen.getByTitle(/without an account/i)).toHaveStyle({ fontSize: 'calc(10px * var(--fs-scale-caption, 1))' })
  })

  it('FE-W4GB-003: shrinks to 9px in the xs variant', () => {
    render(<GuestBadge size="xs" />)
    expect(screen.getByTitle(/without an account/i)).toHaveStyle({ fontSize: 'calc(9px * var(--fs-scale-caption, 1))' })
  })

  it('FE-W4GB-004: with customTooltip the hint moves from the native title into the app tooltip', async () => {
    render(<GuestBadge customTooltip />)
    expect(screen.queryByTitle(/without an account/i)).toBeNull()

    fireEvent.mouseEnter(screen.getByText('Guest'))
    expect(await screen.findByRole('tooltip')).toHaveTextContent(/without an account/i)
  })
})