mobile bluesky app made with flutter
lazurite.stormlightlabs.org/
mobile
bluesky
flutter
1import 'package:flutter_test/flutter_test.dart';
2import 'package:lazurite/core/bootstrap/auth_bootstrap.dart';
3import 'package:lazurite/features/auth/data/auth_repository.dart';
4import 'package:lazurite/features/auth/data/models/auth_models.dart';
5import 'package:mocktail/mocktail.dart';
6
7class MockAuthRepository extends Mock implements AuthRepository {}
8
9void main() {
10 group('bootstrapAuthDependencies', () {
11 test('loads settings before creating and restoring auth repository', () async {
12 final callOrder = <String>[];
13 final authRepository = MockAuthRepository();
14 const restoredSession = AuthTokens(accessToken: 'token', did: 'did:plc:test', handle: 'user.bsky.social');
15
16 final result = await bootstrapAuthDependencies(
17 loadSettings: () async {
18 callOrder.add('loadSettings');
19 },
20 createAuthRepository: () {
21 callOrder.add('createAuthRepository');
22 return authRepository;
23 },
24 restoreSession: (repository) async {
25 expect(repository, same(authRepository));
26 callOrder.add('restoreSession');
27 return restoredSession;
28 },
29 );
30
31 expect(callOrder, equals(<String>['loadSettings', 'createAuthRepository', 'restoreSession']));
32 expect(result.authRepository, same(authRepository));
33 expect(result.restoredSession, same(restoredSession));
34 });
35 });
36}