-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'test/appl-user-details' into test/application
- Loading branch information
Showing
3 changed files
with
55 additions
and
113 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:bloc_test/bloc_test.dart'; | ||
import 'package:collaction_app/application/user_details/user_details_bloc.dart'; | ||
import 'package:collaction_app/domain/user/user.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
|
||
import 'user_details_fixtures.dart'; | ||
|
||
void main() { | ||
group('test User Details BLoC', () { | ||
final UserDetailsBloc tUserBloc = UserDetailsBloc(tUserRepo); | ||
|
||
test('testing Initial UserDetails BLoC State', () { | ||
expect(tUserBloc.state, const UserDetailsState.initial()); | ||
}); | ||
|
||
when(() => tUserRepo.observeUser()).thenAnswer((_) { | ||
final x = StreamController<User>(); | ||
x.add(tUser); | ||
print('x.stream is User? ${x.stream.distinct() is Stream<User>}'); | ||
return x.stream.distinct(); | ||
}); | ||
|
||
blocTest( | ||
'testing fetchDetails event', | ||
build: () => tUserBloc, | ||
act: (UserDetailsBloc bloc) { | ||
bloc.add(const UserDetailsEvent.fetchDetails()); | ||
}, | ||
expect: () => [ | ||
const UserDetailsState.fetchingDetails(), | ||
const UserDetailsState.fetchingDetailsFailed(), | ||
], | ||
); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:collaction_app/domain/user/i_user_repository.dart'; | ||
import 'package:collaction_app/domain/user/user.dart'; | ||
|
||
import 'package:mocktail/mocktail.dart'; | ||
|
||
class MockUserRepository extends Mock implements IUserRepository {} | ||
|
||
final IUserRepository tUserRepo = MockUserRepository(); | ||
|
||
// ignore: avoid_positional_boolean_parameters | ||
Future<String?> testGetAnonymousTokenId([bool forceRefresh = false]) => | ||
Future.value(null); | ||
|
||
const User tUser = User( | ||
id: 'tId', | ||
getIdToken: testGetAnonymousTokenId, | ||
); |