Last active
October 19, 2019 02:47
-
-
Save felangel/6b5be778a646529656e1a381f2de8d58 to your computer and use it in GitHub Desktop.
[flutter_login_unit_test] AuthenticationBloc Tests
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
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:mockito/mockito.dart'; | |
import 'package:user_repository/user_repository.dart'; | |
import 'package:flutter_login/authentication/authentication.dart'; | |
class MockUserRepository extends Mock implements UserRepository {} | |
void main() { | |
AuthenticationBloc authenticationBloc; | |
MockUserRepository userRepository; | |
setUp(() { | |
userRepository = MockUserRepository(); | |
authenticationBloc = AuthenticationBloc(userRepository: userRepository); | |
}); | |
tearDown(() { | |
authenticationBloc?.close(); | |
}); | |
test('initial state is correct', () { | |
expect(authenticationBloc.initialState, AuthenticationUninitialized()); | |
}); | |
test('close does not emit new states', () { | |
expectLater( | |
authenticationBloc, | |
emitsInOrder([AuthenticationUninitialized(), emitsDone]), | |
); | |
authenticationBloc.close(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment