forked from baron/baron-sso
37 lines
1.1 KiB
Dart
37 lines
1.1 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:userfront/core/i18n/locale_registry.dart';
|
|
|
|
void main() {
|
|
tearDown(() {
|
|
LocaleRegistry.resetForTest();
|
|
});
|
|
|
|
group('locale_registry', () {
|
|
test(
|
|
'extractSupportedLocaleCodesFromAssets excludes template and invalid',
|
|
() {
|
|
final locales = extractSupportedLocaleCodesFromAssets([
|
|
'assets/translations/template.toml',
|
|
'assets/translations/en.toml',
|
|
'assets/translations/ko.toml',
|
|
'assets/translations/pt_BR.toml',
|
|
'assets/translations/readme.txt',
|
|
'assets/translations/nested/ja.toml',
|
|
]);
|
|
|
|
expect(locales, ['en', 'ko']);
|
|
},
|
|
);
|
|
|
|
test('fallback locale prefers en when available', () {
|
|
LocaleRegistry.setSupportedLocaleCodesForTest(['ko', 'en']);
|
|
expect(LocaleRegistry.fallbackLocaleCode, 'en');
|
|
});
|
|
|
|
test('fallback locale uses first sorted code when en is absent', () {
|
|
LocaleRegistry.setSupportedLocaleCodesForTest(['ko', 'ja']);
|
|
expect(LocaleRegistry.fallbackLocaleCode, 'ja');
|
|
});
|
|
});
|
|
}
|