halkyon/packages/halkyon_app/test/instance/country_names_test.dart
Tizian 「ティツィアーン」 87500b7c6b
refactor(halkyon_app): the account section, About, the language and countries' names, shared
What Learn and Todo each held now comes from halkyon_app:
- AccountTiles: whose account on which instance, switching, signing
  out (asking first for an anonymous account, as it deletes it) and
  deleting it (asking first), the app's own words passed in.
- showAppAbout: the app's name, version, icon and legalese as it gives
  them, the source of what the instance runs (AppDependencies gains
  sourceCodeUrl), the app's own parts, the licence list.
- resolveAppLocale: the first preferred language the app speaks, never
  by country alone, British English otherwise.
- AssetCountryNames, the default of InstanceGate and InstanceScope:
  Unicode CLDR 48.2's territory names in English and German
  (tool/country_names.py, 7.6 KB), Hong Kong, Macao, Myanmar and
  Palestine by their short names as Learn's world map has them, so
  Todo says "Germany (EU)" where it said "DE (EU)".

Learn's texts read as before in every language; its About bloc and
gateway, its country names from the world map and the keys only the
moved code used are gone, as are Todo's copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-10-22 18:11:08 +02:00

43 lines
1.8 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_app/halkyon_app.dart';
void main() {
test('a country is named in the language asked for, else in English, and '
'one without a name not at all', () async {
final names = MemoryCountryNames({
'CH': {'de': 'Schweiz', 'en': 'Switzerland'},
});
expect(await names.nameOf('CH', 'de'), 'Schweiz');
expect(await names.nameOf('ch', 'de'), 'Schweiz');
expect(await names.nameOf('CH', 'ja'), 'Switzerland');
expect(await names.nameOf('XX', 'en'), isNull);
});
testWidgets("Unicode CLDR's names come with the package, in English and "
'German', (tester) async {
final names = await tester.runAsync(
() async => (
germany: await const AssetCountryNames().nameOf('DE', 'en'),
deutschland: await const AssetCountryNames().nameOf('de', 'de'),
states: await const AssetCountryNames().nameOf('US', 'de'),
kingdom: await const AssetCountryNames().nameOf('GB', 'de'),
switzerland: await const AssetCountryNames().nameOf('CH', 'ja'),
kosovo: await const AssetCountryNames().nameOf('XK', 'en'),
// The union is the package's own words (instanceEuropeanUnion),
// and a region of the world no country.
union: await const AssetCountryNames().nameOf('EU', 'en'),
unknown: await const AssetCountryNames().nameOf('ZZ', 'en'),
),
);
expect(names?.germany, 'Germany');
expect(names?.deutschland, 'Deutschland');
expect(names?.states, 'Vereinigte Staaten');
expect(names?.kingdom, 'Vereinigtes Königreich');
expect(names?.switzerland, 'Switzerland', reason: 'English otherwise');
expect(names?.kosovo, 'Kosovo');
expect(names?.union, isNull);
expect(names?.unknown, isNull);
});
}