import { describe, it, expect } from 'vitest' import { cotAirIconKind, cotCategory, formatCotPopup, getCotIconHtml, } from '../../app/utils/cotDisplay.js' const esc = s => String(s) describe('cotDisplay', () => { it('detects helicopter from CoT type', () => { expect(cotAirIconKind({ type: 'a-f-A-C-H' })).toBe('helicopter') expect(cotAirIconKind({ type: 'a-f-A-C-F' })).toBe('fixedWing') }) it('renders distinct air icon kinds', () => { const plane = getCotIconHtml({ type: 'a-f-A-C-F', heading: 90 }) const heli = getCotIconHtml({ type: 'a-f-A-C-H', heading: 180 }) expect(plane.className).toBe('cot-entity-fixedWing') expect(heli.className).toBe('cot-entity-helicopter') expect(plane.html).toContain('rotate(90deg)') expect(heli.html).toContain('rotate(180deg)') }) it('formats rich ADS-B popup', () => { const html = formatCotPopup({ source: 'adsb', type: 'a-f-A-C-F', label: 'UAL123', icao: 'abc123', originCountry: 'United States', altitude: 10000, speed: 200, heading: 270, verticalRate: 5, squawk: '1200', }, esc) expect(html).toContain('UAL123') expect(html).toContain('Aircraft') expect(html).toContain('ICAO ABC123') expect(html).toContain('United States') expect(html).toContain('ft') expect(html).toContain('kt') expect(html).toContain('270°') expect(html).toContain('Squawk 1200') }) it('formats vessel popup with MMSI', () => { const html = formatCotPopup({ source: 'ais', type: 'a-f-S-C', label: 'TEST SHIP', id: 'MMSI.366123456', speed: 12, heading: 90, }, esc) expect(html).toContain('Vessel') expect(html).toContain('MMSI 366123456') }) it('formats team popup', () => { expect(cotCategory('a-f-G-U-C')).toBe('ground') const html = formatCotPopup({ type: 'a-f-G-U-C', label: 'Alpha 1' }, esc) expect(html).toContain('Team') expect(html).toContain('Alpha 1') }) })