import { describe, expect, it } from 'vitest';
import { normalizeStationRecord, toHttpsIfHttp } from './stationHelpers.js';

describe('stationHelpers', () => {
  it('upgrades plain http stream URLs to https', () => {
    expect(toHttpsIfHttp('http://example.com/stream')).toBe('https://example.com/stream');
    expect(toHttpsIfHttp('https://example.com/stream')).toBe('https://example.com/stream');
  });

  it('normalizes station records into the player shape', () => {
    const station = normalizeStationRecord({
      id: 'station-1',
      name: 'Radio Test',
      streamUrl: 'https://example.com/live',
      tags: ['news'],
    });

    expect(station.id).toBe('station-1');
    expect(station.name).toBe('Radio Test');
    expect(station.url).toBe('https://example.com/live');
    expect(station.streams.audio).toBe('https://example.com/live');
    expect(station.tags).toEqual(['news']);
  });
});
