import { describe, expect, it } from 'vitest';
import { resolvePaddleLocale } from '../steps/PaymentStep';

describe('resolvePaddleLocale', () => {
  it('returns short locale when given region-specific tag', () => {
    expect(resolvePaddleLocale('de-DE')).toBe('de');
    expect(resolvePaddleLocale('en-US')).toBe('en');
  });

  it('falls back to english when locale unsupported', () => {
    expect(resolvePaddleLocale('jp')).toBe('en');
    expect(resolvePaddleLocale('xx-YY')).toBe('en');
    expect(resolvePaddleLocale(undefined)).toBe('en');
  });

  it('keeps supported locale codes untouched', () => {
    expect(resolvePaddleLocale('fr')).toBe('fr');
    expect(resolvePaddleLocale('es')).toBe('es');
  });
});
