37 lines
1.0 KiB
Dart
37 lines
1.0 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:tdc114plus/src/features/auth/data/auth_session_store.dart';
|
|
import 'package:tdc114plus/src/features/auth/domain/auth_models.dart';
|
|
|
|
void main() {
|
|
setUp(() {
|
|
SharedPreferences.setMockInitialValues({});
|
|
});
|
|
|
|
test('saves loads and clears login session', () async {
|
|
const store = AuthSessionStore();
|
|
final response = PhoneLoginResponse(
|
|
status: 'ok',
|
|
token: 'session-token',
|
|
expiresAt: DateTime.parse('2026-07-02T12:00:00Z'),
|
|
user: const LoginUser(
|
|
id: 'user-uuid',
|
|
name: 'User One',
|
|
phoneNumber: '+821012345678',
|
|
tenantId: 'tenant-uuid',
|
|
tenantName: 'Hanmac',
|
|
tenantSlug: 'hanmac',
|
|
),
|
|
);
|
|
|
|
await store.save(response);
|
|
final loaded = await store.load();
|
|
|
|
expect(loaded?.token, 'session-token');
|
|
expect(loaded?.user.name, 'User One');
|
|
|
|
await store.clear();
|
|
expect(await store.load(), isNull);
|
|
});
|
|
}
|