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); }); }