WT1.1.6+3 bodyType animation, bug fixes

This commit is contained in:
bossanyit
2021-02-20 16:48:01 +01:00
parent 3c5360f224
commit cf348cebb0
293 changed files with 2966 additions and 1673 deletions
+36 -42
View File
@@ -4,9 +4,7 @@ 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 {
}
class MockCustomerRepository extends Mock implements CustomerRepository {}
void main() {
MockCustomerRepository customerRepository;
@@ -16,7 +14,7 @@ void main() {
test.setUp(() {
customerRepository = MockCustomerRepository();
accountBloc = AccountBloc(customerRepository: customerRepository);
accountBloc = AccountBloc(customerRepository: customerRepository);
});
test.tearDown(() {
@@ -28,52 +26,48 @@ void main() {
});
group('Account', () {
test.test(
'emits [loading, logged in] when the customer clicked login',
() {
final expectedResponse = [
AccountLoading(),
AccountLoggedIn(),
];
test.test('emits [loading, logged in] when the customer clicked login', () {
final expectedResponse = [
AccountLoading(),
AccountLoggedIn(),
];
//verify(accountBloc.customerRepository.customer == null);
//verify(accountBloc.customerRepository.customer == null);
expectLater(
accountBloc, emitsInOrder(expectedResponse),
);
expectLater(
accountBloc,
emitsInOrder(expectedResponse),
);
accountBloc.add(AccountLogin());
});
accountBloc.add(AccountLogin());
});
});
test.test(
'emits [loading, logged out] when the customer clicked logout',
() {
final expectedResponse = [
AccountLoading(),
AccountLoggedOut(),
];
test.test('emits [loading, logged out] when the customer clicked logout', () {
final expectedResponse = [
AccountLoading(),
AccountLoggedOut(),
];
expectLater(
accountBloc, emitsInOrder(expectedResponse),
);
expectLater(
accountBloc,
emitsInOrder(expectedResponse),
);
accountBloc.add(AccountLogout());
});
accountBloc.add(AccountLogout());
});
test.test(
'emits [loading, logged out] when the customer data changed',
() {
final expectedResponse = [
AccountLoading(),
AccountReady(),
];
test.test('emits [loading, logged out] when the customer data changed', () {
final expectedResponse = [
AccountLoading(),
AccountReady(),
];
expectLater(
accountBloc, emitsInOrder(expectedResponse),
);
accountBloc.add(AccountChangeCustomer());
});
expectLater(
accountBloc,
emitsInOrder(expectedResponse),
);
accountBloc.add(AccountChangeCustomer());
});
}
+63
View File
@@ -0,0 +1,63 @@
import 'package:aitrainer_app/bloc/body_type/bodytype_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() {
BodytypeBloc bloc;
TestWidgetsFlutterBinding.ensureInitialized();
test.setUp(() {
bloc = BodytypeBloc();
});
test.tearDown(() {
bloc.close();
});
test.test('initial state is correct', () {
expect(bloc.state, BodytypeInitial());
});
group('getValueByWeight', () {
test.test('check differnt weights and answers', () {
List<int> weights = [0, 3, 7];
List<int> answers = [1, 2, 3, 4, 5];
expect(bloc.getValueByWeight(weights[0], answers[4]), 0);
expect(bloc.getValueByWeight(weights[0], answers[3]), 1);
expect(bloc.getValueByWeight(weights[0], answers[2]), 3);
expect(bloc.getValueByWeight(weights[0], answers[1]), 5);
expect(bloc.getValueByWeight(weights[0], answers[0]), 7);
expect(bloc.getValueByWeight(weights[1], answers[4]), 3);
expect(bloc.getValueByWeight(weights[1], answers[3]), 4);
expect(bloc.getValueByWeight(weights[1], answers[2]), 6);
expect(bloc.getValueByWeight(weights[1], answers[1]), 4);
expect(bloc.getValueByWeight(weights[1], answers[0]), 3);
expect(bloc.getValueByWeight(weights[2], answers[4]), 7);
expect(bloc.getValueByWeight(weights[2], answers[3]), 5);
expect(bloc.getValueByWeight(weights[2], answers[2]), 3);
expect(bloc.getValueByWeight(weights[2], answers[1]), 1);
expect(bloc.getValueByWeight(weights[2], answers[0]), 0);
List<int> weights2 = [5, 5, 0];
expect(bloc.getValueByWeight(weights2[0], answers[4]), 5);
expect(bloc.getValueByWeight(weights2[0], answers[3]), 4);
expect(bloc.getValueByWeight(weights2[0], answers[2]), 3);
expect(bloc.getValueByWeight(weights2[0], answers[1]), 2);
expect(bloc.getValueByWeight(weights2[0], answers[0]), 1);
expect(bloc.getValueByWeight(weights2[2], answers[4]), 0);
expect(bloc.getValueByWeight(weights2[2], answers[3]), 1);
expect(bloc.getValueByWeight(weights2[2], answers[2]), 3);
expect(bloc.getValueByWeight(weights2[2], answers[1]), 5);
expect(bloc.getValueByWeight(weights2[2], answers[0]), 7);
});
});
}