halkyon/packages/halkyon_app/test/instance/subdivision_names_test.dart

36 lines
1.4 KiB
Dart
Raw Normal View History

import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_app/halkyon_app.dart';
void main() {
test('a subdivision is named in the language asked for, else in English, '
'and one without a name not at all', () async {
const names = MemorySubdivisionNames({
'US-CA': {'en': 'California', 'de': 'Kalifornien'},
'US-TX': {'en': 'Texas'},
});
expect(await names.nameOf('US-CA', 'de'), 'Kalifornien');
expect(await names.nameOf('us-ca', 'de'), 'Kalifornien');
expect(await names.nameOf('US-TX', 'de'), 'Texas');
expect(await names.nameOf('US-ZZ', 'en'), isNull);
});
testWidgets("Unicode CLDR's names come with the package, in English and "
'German', (tester) async {
final names = await tester.runAsync(
() async => (
en: await const AssetSubdivisionNames().nameOf('US-CA', 'en'),
de: await const AssetSubdivisionNames().nameOf('US-CA', 'de'),
texas: await const AssetSubdivisionNames().nameOf('US-TX', 'de'),
scotland: await const AssetSubdivisionNames().nameOf('GB-SCT', 'de'),
unknown: await const AssetSubdivisionNames().nameOf('US-ZZ', 'en'),
),
);
expect(names?.en, 'California');
expect(names?.de, 'Kalifornien');
expect(names?.texas, 'Texas', reason: 'German as English, kept once');
expect(names?.scotland, 'Schottland');
expect(names?.unknown, isNull);
});
}