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.

918 B
Raw Blame
import { describe, it, expect } from 'vitest'
import { ratingBadgeHtml } from './ratingBadge'

describe('ratingBadgeHtml', () => {
  it('FE-MAP-RATINGBADGE-001: shows a whole rating without a decimal', () => {
    // "4" reads faster than "4.0", and at this size every character costs.
    expect(ratingBadgeHtml(4)).toContain('>4<')
    expect(ratingBadgeHtml(4)).not.toContain('4.0')
  })

  it('FE-MAP-RATINGBADGE-002: keeps one decimal where an average has one', () => {
    expect(ratingBadgeHtml(4.5)).toContain('>4.5<')
    expect(ratingBadgeHtml(4.25)).toContain('>4.3<')
  })

  it('FE-MAP-RATINGBADGE-003: draws nothing without a rating', () => {
    // An unrated place is most of them. A badge on every marker would say nothing and
    // cover the photo it sits on.
    expect(ratingBadgeHtml(null)).toBe('')
    expect(ratingBadgeHtml(undefined)).toBe('')
    expect(ratingBadgeHtml(0)).toBe('')
  })
})