import { describe, expect, it } from 'vitest';
import { formatTelemetryTime, formatTelemetryValue, telemetryQualityLabel } from './telemetry';

describe('latest telemetry presentation', () => {
  it('formats server-authoritative scalar values without inferring metadata', () => {
    expect(formatTelemetryValue(42.567)).toBe('42.57');
    expect(formatTelemetryValue(true)).toBe('是');
    expect(formatTelemetryValue(null)).toBe('—');
  });

  it('translates server quality states', () => {
    expect(telemetryQualityLabel('good')).toBe('正常');
    expect(telemetryQualityLabel('stale')).toBe('陈旧');
    expect(telemetryQualityLabel('warning')).toBe('异常');
  });

  it('keeps telemetry timestamps compact for local and RFC3339 values', () => {
    expect(formatTelemetryTime('2026-07-14T09:24:34+08:00')).toBe('09:24:34');
    expect(formatTelemetryTime('2026-07-14 09:24:34')).toBe('09:24:34');
  });
});
