55 lines
1.7 KiB
Dart
55 lines
1.7 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'arb_test_helpers.dart';
|
|
|
|
/// WU18 task 18.1 / 18.2 -- ARB key-parity guard.
|
|
///
|
|
/// `l10n.yaml` sets `template-arb-file: app_es.arb`, so Spanish is the l10n
|
|
/// template: any key missing from a locale's ARB silently falls back to the
|
|
/// Spanish value at runtime (not English, which is the more common
|
|
/// assumption). This test guarantees all 13 locales carry the same key set,
|
|
/// so nothing can silently render in Spanish because a locale was never
|
|
/// given that key.
|
|
void main() {
|
|
test('all 13 ARB files declare an identical key set', () {
|
|
final arbs = {
|
|
for (final locale in supportedArbLocales) locale: readArb(locale),
|
|
};
|
|
final templateKeys = realKeys(arbs['es']!);
|
|
|
|
for (final locale in supportedArbLocales) {
|
|
if (locale == 'es') continue;
|
|
final keys = realKeys(arbs[locale]!);
|
|
final missing = templateKeys.difference(keys);
|
|
final extra = keys.difference(templateKeys);
|
|
|
|
expect(
|
|
missing,
|
|
isEmpty,
|
|
reason:
|
|
'app_$locale.arb is missing ${missing.length} key(s) present in '
|
|
'the es template (these silently fall back to Spanish at '
|
|
'runtime): $missing',
|
|
);
|
|
expect(
|
|
extra,
|
|
isEmpty,
|
|
reason:
|
|
'app_$locale.arb has ${extra.length} key(s) not present in the '
|
|
'es template: $extra',
|
|
);
|
|
}
|
|
});
|
|
|
|
test('navHome exists as a key in all 13 locales', () {
|
|
for (final locale in supportedArbLocales) {
|
|
final arb = readArb(locale);
|
|
expect(
|
|
realKeys(arb).contains('navHome'),
|
|
isTrue,
|
|
reason: 'app_$locale.arb is missing the navHome key',
|
|
);
|
|
}
|
|
});
|
|
}
|