Skip to content

Instantly share code, notes, and snippets.

@felangel
Last active October 19, 2019 02:47
Show Gist options
  • Save felangel/6b5be778a646529656e1a381f2de8d58 to your computer and use it in GitHub Desktop.
Save felangel/6b5be778a646529656e1a381f2de8d58 to your computer and use it in GitHub Desktop.
[flutter_login_unit_test] AuthenticationBloc Tests
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