wt1.1c auth->cache, control page, animation base exercise percent
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
import 'package:aitrainer_app/bloc/account/account_bloc.dart';
|
||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:test/test.dart' as test;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
class MockCustomerRepository extends Mock implements CustomerRepository {
|
||||
|
||||
}
|
||||
|
||||
void main() {
|
||||
MockCustomerRepository customerRepository;
|
||||
AccountBloc accountBloc;
|
||||
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
test.setUp(() {
|
||||
customerRepository = MockCustomerRepository();
|
||||
accountBloc = AccountBloc(customerRepository: customerRepository);
|
||||
});
|
||||
|
||||
test.tearDown(() {
|
||||
accountBloc?.close();
|
||||
});
|
||||
|
||||
test.test('initial state is correct', () {
|
||||
expect(accountBloc.state, AccountInitial());
|
||||
});
|
||||
|
||||
group('Account', () {
|
||||
test.test(
|
||||
'emits [loading, logged in] when the customer clicked login',
|
||||
() {
|
||||
final expectedResponse = [
|
||||
AccountLoading(),
|
||||
AccountLoggedIn(),
|
||||
];
|
||||
|
||||
//verify(accountBloc.customerRepository.customer == null);
|
||||
|
||||
expectLater(
|
||||
accountBloc, emitsInOrder(expectedResponse),
|
||||
);
|
||||
|
||||
accountBloc.add(AccountLogin());
|
||||
});
|
||||
});
|
||||
|
||||
test.test(
|
||||
'emits [loading, logged out] when the customer clicked logout',
|
||||
() {
|
||||
final expectedResponse = [
|
||||
AccountLoading(),
|
||||
AccountLoggedOut(),
|
||||
];
|
||||
|
||||
expectLater(
|
||||
accountBloc, emitsInOrder(expectedResponse),
|
||||
);
|
||||
|
||||
accountBloc.add(AccountLogout());
|
||||
});
|
||||
|
||||
test.test(
|
||||
'emits [loading, logged out] when the customer data changed',
|
||||
() {
|
||||
final expectedResponse = [
|
||||
AccountLoading(),
|
||||
AccountReady(),
|
||||
];
|
||||
|
||||
expectLater(
|
||||
accountBloc, emitsInOrder(expectedResponse),
|
||||
);
|
||||
|
||||
accountBloc.add(AccountChangeCustomer());
|
||||
});
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
|
||||
|
||||
class MockUserRepository extends Mock implements UserRepository {
|
||||
class MockUserRepository extends Mock implements UserRepository {
|
||||
final User user = User();
|
||||
|
||||
setEmail(String email) {
|
||||
@@ -43,15 +43,23 @@ class MockUserRepository extends Mock implements UserRepository {
|
||||
class MockLoginBloc extends MockBloc<FormBlocEvent>
|
||||
implements LoginFormBloc {}
|
||||
|
||||
class MockCommon with Common {
|
||||
String getEmailError() {
|
||||
return EMAIL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
group('LoginScreen', () {
|
||||
MockLoginBloc loginBloc;
|
||||
MockUserRepository userRepository;
|
||||
Widget loginWidget;
|
||||
MockCommon common;
|
||||
|
||||
setUp(() {
|
||||
loginBloc = MockLoginBloc();
|
||||
userRepository = MockUserRepository();
|
||||
common = MockCommon();
|
||||
|
||||
loginWidget =
|
||||
MaterialApp(
|
||||
@@ -100,7 +108,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(okButton);
|
||||
await tester.pump(const Duration(milliseconds: 500)); // add delay
|
||||
final emailErrorFinder = find.text(Common.EMAIL_ERROR);
|
||||
final emailErrorFinder = find.text(common.getEmailError());
|
||||
expect(emailErrorFinder, findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user