import { describe, expect, it } from 'vitest';
import { normalizeSubtype } from './platform';

describe('normalizeSubtype', () => {
  it('maps iPhone and iPad variants to the store-frozen ios', () => {
    expect(normalizeSubtype('ios')).toBe('ios');
    expect(normalizeSubtype('iphone')).toBe('ios');
    expect(normalizeSubtype('mobile_iphone')).toBe('ios');
    expect(normalizeSubtype('mobile_ipad')).toBe('ios');
  });

  it('maps android variants to android', () => {
    expect(normalizeSubtype('android')).toBe('android');
    expect(normalizeSubtype('mobile_android')).toBe('android');
    expect(normalizeSubtype('android_x')).toBe('android');
  });

  it('is case-insensitive', () => {
    expect(normalizeSubtype('IPhone')).toBe('ios');
    expect(normalizeSubtype('Android')).toBe('android');
  });

  it('defaults desktop, tdesktop, web, empty and unknown values to web', () => {
    expect(normalizeSubtype('web')).toBe('web');
    expect(normalizeSubtype('mobile_web')).toBe('web');
    expect(normalizeSubtype('desktop_web')).toBe('web');
    expect(normalizeSubtype('tdesktop')).toBe('web');
    expect(normalizeSubtype('')).toBe('web');
    expect(normalizeSubtype('something_new')).toBe('web');
  });
});
