forked from baron/baron-sso
76 lines
2.0 KiB
Dart
76 lines
2.0 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:userfront/core/i18n/locale_storage.dart';
|
|
import 'package:userfront/core/i18n/locale_storage_backend.dart';
|
|
|
|
void main() {
|
|
setUp(() {
|
|
LocaleStorage.setTestModeForTests(LocaleStorageTestMode.normal);
|
|
LocaleStorage.clearForTests();
|
|
});
|
|
|
|
tearDown(() {
|
|
LocaleStorage.setTestModeForTests(LocaleStorageTestMode.normal);
|
|
LocaleStorage.clearForTests();
|
|
});
|
|
|
|
test('localStorage write/read (웹)', () {
|
|
if (!kIsWeb) {
|
|
return;
|
|
}
|
|
|
|
LocaleStorage.write('ko');
|
|
expect(LocaleStorage.read(), 'ko');
|
|
|
|
final state = LocaleStorage.debugStateForTests();
|
|
expect(state.localCurrent, 'ko');
|
|
expect(state.sessionCurrent, isNull);
|
|
expect(state.memoryCurrent, isNull);
|
|
}, skip: !kIsWeb);
|
|
|
|
test('legacy key에서 locale로 마이그레이션 (웹)', () {
|
|
if (!kIsWeb) {
|
|
return;
|
|
}
|
|
|
|
LocaleStorage.seedLegacyForTests('en');
|
|
expect(LocaleStorage.read(), 'en');
|
|
|
|
final state = LocaleStorage.debugStateForTests();
|
|
expect(state.localCurrent, 'en');
|
|
expect(state.localLegacy, isNull);
|
|
}, skip: !kIsWeb);
|
|
|
|
test('localStorage 접근이 차단되면 메모리 fallback (웹)', () {
|
|
if (!kIsWeb) {
|
|
return;
|
|
}
|
|
|
|
LocaleStorage.forceMemoryStorageForTests(true);
|
|
|
|
LocaleStorage.write('en');
|
|
expect(LocaleStorage.read(), 'en');
|
|
|
|
final state = LocaleStorage.debugStateForTests();
|
|
expect(state.localCurrent, isNull);
|
|
expect(state.sessionCurrent, isNull);
|
|
expect(state.memoryCurrent, 'en');
|
|
}, skip: !kIsWeb);
|
|
|
|
test('localStorage 접근이 차단되면 sessionStorage로 fallback (웹)', () {
|
|
if (!kIsWeb) {
|
|
return;
|
|
}
|
|
|
|
LocaleStorage.forceSessionStorageForTests(true);
|
|
|
|
LocaleStorage.write('ko');
|
|
expect(LocaleStorage.read(), 'ko');
|
|
|
|
final state = LocaleStorage.debugStateForTests();
|
|
expect(state.localCurrent, isNull);
|
|
expect(state.sessionCurrent, 'ko');
|
|
expect(state.memoryCurrent, isNull);
|
|
}, skip: !kIsWeb);
|
|
}
|