mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-26 09:20:45 +00:00
SupportedLocale
tests
This commit is contained in:
parent
83dd6228cf
commit
d935d7f6de
2 changed files with 16 additions and 15 deletions
|
@ -1,20 +1,5 @@
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
|
|
||||||
enum SupportedLocale { en, fr, ru }
|
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 {
|
extension SupportedLocaleExtension on SupportedLocale {
|
||||||
String get intlName => toString().replaceAll("SupportedLocale.", "");
|
String get intlName => toString().replaceAll("SupportedLocale.", "");
|
||||||
|
|
||||||
|
|
16
test/data/models/supported_locale_test.dart
Normal file
16
test/data/models/supported_locale_test.dart
Normal 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, 'Русский');
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue