import { describe, expect, it } from 'vitest';
import { detectChannel } from './channel';

describe('detectChannel', () => {
  it('prefers telegram over everything', () => {
    expect(detectChannel({ telegram: true })).toBe('telegram');
    expect(detectChannel({ telegram: true, capacitorPlatform: 'ios' })).toBe('telegram');
  });

  it('maps the native Capacitor platforms', () => {
    expect(detectChannel({ telegram: false, capacitorPlatform: 'ios' })).toBe('ios');
    expect(detectChannel({ telegram: false, capacitorPlatform: 'android' })).toBe('android');
  });

  it('falls back to web for capacitor web, missing, or unknown platforms', () => {
    expect(detectChannel({ telegram: false, capacitorPlatform: 'web' })).toBe('web');
    expect(detectChannel({ telegram: false })).toBe('web');
    expect(detectChannel({ telegram: false, capacitorPlatform: 'desktop' })).toBe('web');
  });
});
