import { describe, expect, it } from 'vitest';

import { isAppLocale, normalizeAppLocale, pickAppText } from '@/lib/i18n/core';

describe('app locale normalization', () => {
  it('accepts simplified Chinese, English, and traditional Chinese locales', () => {
    expect(isAppLocale('zh-CN')).toBe(true);
    expect(isAppLocale('en-US')).toBe(true);
    expect(isAppLocale('zh-Hant')).toBe(true);
  });

  it('normalizes common traditional Chinese locale tags', () => {
    expect(normalizeAppLocale('zh-TW')).toBe('zh-Hant');
    expect(normalizeAppLocale('zh-HK')).toBe('zh-Hant');
    expect(normalizeAppLocale('zh-Hant')).toBe('zh-Hant');
  });
});

describe('app text picker', () => {
  it('returns simplified Chinese text for zh-CN', () => {
    expect(pickAppText('zh-CN', '任务状态', 'Task status')).toBe('任务状态');
  });

  it('returns English text for en-US', () => {
    expect(pickAppText('en-US', '任务状态', 'Task status')).toBe('Task status');
  });

  it('returns traditional Chinese text for zh-Hant', () => {
    expect(pickAppText('zh-Hant', '任务状态', 'Task status')).toBe('任務狀態');
    expect(pickAppText('zh-Hant', '智能体结果', 'Agent results')).toBe('智慧體結果');
  });
});
