Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

866 B
Raw Blame
import { getIntlLanguage, SUPPORTED_LANGUAGES } from './languages';

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

describe('getIntlLanguage', () => {
  it('maps the two codes that are not the BCP-47 tag of their language', () => {
    expect(getIntlLanguage('br')).toBe('pt-BR');
    expect(getIntlLanguage('gr')).toBe('el');
  });

  it('passes every other supported code through and falls back to English', () => {
    expect(getIntlLanguage('de')).toBe('de');
    expect(getIntlLanguage('zh-TW')).toBe('zh-TW');
    expect(getIntlLanguage('xx')).toBe('en');
  });

  it('gives Intl a tag it formats in the right language for every supported code', () => {
    for (const { value, locale } of SUPPORTED_LANGUAGES) {
      const primary = locale.split('-')[0];
      expect(new Intl.Locale(getIntlLanguage(value)).language, value).toBe(primary);
    }
  });
});