halkyon/packages/halkyon_app/test/instance/widget/instance_flag_test.dart

37 lines
1.1 KiB
Dart
Raw Normal View History

import 'package:flag/flag.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_app/halkyon_app.dart';
import 'package:material_ui/material_ui.dart';
void main() {
test("a place shows the most specific flag there is: a subdivision's own, "
"else its country's, and the European Union's", () {
expect(flagCodeOf('EU'), 'eu');
expect(flagCodeOf('DE'), 'de');
expect(flagCodeOf('CH'), 'ch');
expect(flagCodeOf('DE-BY'), 'de');
expect(flagCodeOf('US-CA'), 'us');
expect(flagCodeOf('GB-SCT'), 'gb_sct');
expect(flagCodeOf('ES-CT'), 'es_ct');
expect(flagCodeOf('DE-ZZ'), 'de');
});
test('a place without a flag shows none', () {
expect(flagCodeOf('QQ'), isNull);
expect(flagCodeOf('QQ-AB'), isNull);
});
testWidgets("a state shows its country's flag, a place without one "
'nothing', (tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: Row(
children: [InstanceFlag('US-CA'), InstanceFlag('QQ-AB')],
),
),
);
expect(find.byType(Flag), findsOne);
});
}