SupportedLocale tests

This commit is contained in:
Vadim 2023-06-21 08:58:55 +02:00
parent 83dd6228cf
commit d935d7f6de
2 changed files with 16 additions and 15 deletions

View file

@ -1,20 +1,5 @@
import 'package:intl/intl.dart';
enum SupportedLocale { en, fr, ru }
SupportedLocale get currentLanguage {
switch (Intl.getCurrentLocale()) {
case "en":
return SupportedLocale.en;
case "fr":
return SupportedLocale.fr;
case "ru":
return SupportedLocale.ru;
default:
return SupportedLocale.en;
}
}
extension SupportedLocaleExtension on SupportedLocale {
String get intlName => toString().replaceAll("SupportedLocale.", "");

View file

@ -0,0 +1,16 @@
import 'package:lightmeter/data/models/supported_locale.dart';
import 'package:test/test.dart';
void main() {
test('intlName', () {
expect(SupportedLocale.en.intlName, 'en');
expect(SupportedLocale.fr.intlName, 'fr');
expect(SupportedLocale.ru.intlName, 'ru');
});
test('localizedName', () {
expect(SupportedLocale.en.localizedName, 'English');
expect(SupportedLocale.fr.localizedName, 'Français');
expect(SupportedLocale.ru.localizedName, 'Русский');
});
}