WT1.1.11 Null-Safe migration
This commit is contained in:
@@ -8,7 +8,7 @@ class MockCustomerRepository extends Mock implements CustomerRepository {}
|
||||
|
||||
void main() {
|
||||
MockCustomerRepository customerRepository;
|
||||
AccountBloc accountBloc;
|
||||
late AccountBloc accountBloc;
|
||||
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
@@ -18,7 +18,7 @@ void main() {
|
||||
});
|
||||
|
||||
test.tearDown(() {
|
||||
accountBloc?.close();
|
||||
accountBloc.close();
|
||||
});
|
||||
|
||||
test.test('initial state is correct', () {
|
||||
|
||||
@@ -7,12 +7,12 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
class MockCustomerRepository extends Mock implements CustomerRepository {}
|
||||
|
||||
void main() {
|
||||
BodytypeBloc bloc;
|
||||
late BodytypeBloc bloc;
|
||||
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
test.setUp(() {
|
||||
bloc = BodytypeBloc();
|
||||
bloc = BodytypeBloc(repository: MockCustomerRepository());
|
||||
});
|
||||
|
||||
test.tearDown(() {
|
||||
|
||||
@@ -23,29 +23,27 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
} */
|
||||
|
||||
main() {
|
||||
setUp(() {
|
||||
Cache().setTestBaseUrl();
|
||||
});
|
||||
|
||||
group('fetchPost', () {
|
||||
test('returns a List<Customer> if the http call completes successfully', () async {
|
||||
final client = CustomerApi();
|
||||
|
||||
setUp(() {
|
||||
Cache().setTestBaseUrl();
|
||||
// Use Mockito to return a successful response when it calls the
|
||||
// provided http.Client.
|
||||
List<Customer> trainees = [];
|
||||
trainees = await client.getTrainees(62);
|
||||
|
||||
expect(trainees.length, 2);
|
||||
expect(trainees[0].firstname, "Zalán");
|
||||
});
|
||||
|
||||
group('fetchPost', () {
|
||||
test('returns a List<Customer> if the http call completes successfully', () async {
|
||||
final client = CustomerApi();
|
||||
test('throws an exception if the http call completes with an error', () async {
|
||||
final client = CustomerApi();
|
||||
|
||||
// Use Mockito to return a successful response when it calls the
|
||||
// provided http.Client.
|
||||
List<Customer> trainees = List<Customer>();
|
||||
trainees = await client.getTrainees(62);
|
||||
|
||||
expect(trainees.length, 2);
|
||||
expect(trainees[0].firstname, "Zalán");
|
||||
});
|
||||
|
||||
test('throws an exception if the http call completes with an error', () async {
|
||||
final client = CustomerApi();
|
||||
|
||||
expect(client.getTrainees(22), throwsException);
|
||||
});
|
||||
expect(client.getTrainees(22), throwsException);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import 'package:test/test.dart';
|
||||
import 'mocks.dart';
|
||||
|
||||
main() {
|
||||
SimExercisePlanRepository _exercisePlanRepository;
|
||||
ExercisePlanBloc bloc;
|
||||
late SimExercisePlanRepository _exercisePlanRepository;
|
||||
late ExercisePlanBloc bloc;
|
||||
|
||||
Future<void> setUpPlan() async {
|
||||
final String planName2 = "Test Plan2";
|
||||
@@ -73,10 +73,10 @@ main() {
|
||||
emitsInOrder(expectedResponse),
|
||||
).then((_) {
|
||||
expect(bloc.exercisePlanRepository.newPlan, false);
|
||||
expect(bloc.exercisePlanRepository.exercisePlan.name, "Test Plan2");
|
||||
expect(bloc.exercisePlanRepository.exercisePlanDetails[4].weightEquation, "95");
|
||||
expect(Cache().getMyExercisePlan().name, "Test Plan2");
|
||||
expect(Cache().getMyExercisePlanDetails()[4].weightEquation, "95");
|
||||
expect(bloc.exercisePlanRepository.exercisePlan!.name, "Test Plan2");
|
||||
expect(bloc.exercisePlanRepository.exercisePlanDetails[4]!.weightEquation, "95");
|
||||
expect(Cache().getMyExercisePlan()!.name, "Test Plan2");
|
||||
expect(Cache().getMyExercisePlanDetails()[4]!.weightEquation, "95");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,13 +100,13 @@ main() {
|
||||
emitsInOrder(expectedResponse2),
|
||||
).then((_) {
|
||||
expect(bloc.exercisePlanRepository.newPlan, false);
|
||||
expect(bloc.exercisePlanRepository.exercisePlan.customerId, 101);
|
||||
expect(bloc.exercisePlanRepository.exercisePlan!.customerId, 101);
|
||||
expect(bloc.exercisePlanRepository.exercisePlanDetails.length, 3);
|
||||
expect(bloc.exercisePlanRepository.exercisePlanDetails[5].repeats, 20);
|
||||
expect(bloc.exercisePlanRepository.exercisePlanDetails[5].change, ModelChange.add);
|
||||
expect(Cache().getMyExercisePlan().name, "Test Plan2");
|
||||
expect(Cache().getMyExercisePlanDetails()[5].weightEquation, "55");
|
||||
expect(Cache().getMyExercisePlanDetails()[5].repeats, 20);
|
||||
expect(bloc.exercisePlanRepository.exercisePlanDetails[5]!.repeats, 20);
|
||||
expect(bloc.exercisePlanRepository.exercisePlanDetails[5]!.change, ModelChange.add);
|
||||
expect(Cache().getMyExercisePlan()!.name, "Test Plan2");
|
||||
expect(Cache().getMyExercisePlanDetails()[5]!.weightEquation, "55");
|
||||
expect(Cache().getMyExercisePlanDetails()[5]!.repeats, 20);
|
||||
});
|
||||
});
|
||||
test('Update bloc', () async {
|
||||
@@ -114,9 +114,9 @@ main() {
|
||||
|
||||
bloc.exercisePlanRepository.getLastExercisePlan();
|
||||
bloc.exercisePlanRepository.getExercisePlanDetails();
|
||||
bloc.exercisePlanRepository.exercisePlanDetails[3].repeats = 25;
|
||||
bloc.exercisePlanRepository.exercisePlanDetails[3]!.repeats = 25;
|
||||
|
||||
bloc.add(ExercisePlanAddExercise(exercisePlanDetail: bloc.exercisePlanRepository.exercisePlanDetails[3]));
|
||||
bloc.add(ExercisePlanAddExercise(exercisePlanDetail: bloc.exercisePlanRepository.exercisePlanDetails[3]!));
|
||||
|
||||
final expectedResponse2 = [ExercisePlanLoading(), ExercisePlanReady()];
|
||||
|
||||
@@ -125,15 +125,15 @@ main() {
|
||||
emitsInOrder(expectedResponse2),
|
||||
).then((_) {
|
||||
expect(bloc.exercisePlanRepository.newPlan, false);
|
||||
expect(bloc.exercisePlanRepository.exercisePlanDetails[3].repeats, 25);
|
||||
expect(Cache().getMyExercisePlanDetails()[3].repeats, 25);
|
||||
expect(bloc.exercisePlanRepository.exercisePlanDetails[3]!.repeats, 25);
|
||||
expect(Cache().getMyExercisePlanDetails()[3]!.repeats, 25);
|
||||
});
|
||||
});
|
||||
test('Delete bloc', () async {
|
||||
bloc.customerId = 101;
|
||||
bloc.exercisePlanRepository.getLastExercisePlan();
|
||||
bloc.exercisePlanRepository.getExercisePlanDetails();
|
||||
bloc.add(ExercisePlanRemoveExercise(exercisePlanDetail: bloc.exercisePlanRepository.exercisePlanDetails[3]));
|
||||
bloc.add(ExercisePlanRemoveExercise(exercisePlanDetail: bloc.exercisePlanRepository.exercisePlanDetails[3]!));
|
||||
|
||||
final expectedResponse2 = [ExercisePlanLoading(), ExercisePlanReady()];
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import 'package:test/test.dart';
|
||||
import 'mocks.dart';
|
||||
|
||||
main() {
|
||||
SimExercisePlanRepository _exercisePlanRepository;
|
||||
int _customerId;
|
||||
late SimExercisePlanRepository _exercisePlanRepository;
|
||||
late int _customerId;
|
||||
|
||||
Future<void> setUpPlan() async {
|
||||
final String planName2 = "Test Plan2";
|
||||
@@ -63,11 +63,11 @@ main() {
|
||||
|
||||
await _exercisePlanRepository.saveExercisePlan();
|
||||
|
||||
expect(_exercisePlanRepository.getExercisePlan().name, planName);
|
||||
expect(_exercisePlanRepository.getExercisePlan().exercisePlanId > 0, true);
|
||||
expect(_exercisePlanRepository.getExercisePlan()!.name, planName);
|
||||
expect(_exercisePlanRepository.getExercisePlan()!.exercisePlanId! > 0, true);
|
||||
|
||||
ExercisePlanDetail detail = _exercisePlanRepository.getExercisePlanDetailByExerciseId(55);
|
||||
expect(detail.exercisePlanId, _exercisePlanRepository.getExercisePlan().exercisePlanId);
|
||||
ExercisePlanDetail detail = _exercisePlanRepository.getExercisePlanDetailByExerciseId(55)!;
|
||||
expect(detail.exercisePlanId, _exercisePlanRepository.getExercisePlan()!.exercisePlanId);
|
||||
});
|
||||
test('save new plan and plan details second', () async {
|
||||
int customerId = 100;
|
||||
@@ -92,27 +92,27 @@ main() {
|
||||
|
||||
await _exercisePlanRepository.saveExercisePlan();
|
||||
|
||||
expect(_exercisePlanRepository.getExercisePlan().name, planName);
|
||||
expectLater(_exercisePlanRepository.getExercisePlan().exercisePlanId > 0, true);
|
||||
expect(_exercisePlanRepository.getExercisePlan()!.name, planName);
|
||||
expectLater(_exercisePlanRepository.getExercisePlan()!.exercisePlanId! > 0, true);
|
||||
|
||||
ExercisePlanDetail detail = _exercisePlanRepository.getExercisePlanDetailByExerciseId(13);
|
||||
expect(detail.exercisePlanId, _exercisePlanRepository.getExercisePlan().exercisePlanId);
|
||||
ExercisePlanDetail detail = _exercisePlanRepository.getExercisePlanDetailByExerciseId(13)!;
|
||||
expect(detail.exercisePlanId, _exercisePlanRepository.getExercisePlan()!.exercisePlanId);
|
||||
expect(detail.repeats, 33);
|
||||
});
|
||||
});
|
||||
|
||||
group('Existing Plan', () {
|
||||
test('Get Last Plan and Details from DB', () async {
|
||||
ExercisePlan exercisePlan = await _exercisePlanRepository.getLastExercisePlan();
|
||||
expect(exercisePlan.customerId, 101);
|
||||
ExercisePlan? exercisePlan = await _exercisePlanRepository.getLastExercisePlan();
|
||||
expect(exercisePlan!.customerId, 101);
|
||||
|
||||
await _exercisePlanRepository.getExercisePlanDetails();
|
||||
expect(_exercisePlanRepository.exercisePlanDetails[3].repeats, 23);
|
||||
expect(_exercisePlanRepository.exercisePlanDetails[4].weightEquation, "95");
|
||||
expect(_exercisePlanRepository.exercisePlanDetails[3]!.repeats, 23);
|
||||
expect(_exercisePlanRepository.exercisePlanDetails[4]!.weightEquation, "95");
|
||||
|
||||
//Test Cache
|
||||
expect(Cache().getMyExercisePlan().name, "Test Plan2");
|
||||
expect(Cache().getMyExercisePlanDetails()[3].weightEquation, "60");
|
||||
expect(Cache().getMyExercisePlan()!.name, "Test Plan2");
|
||||
expect(Cache().getMyExercisePlanDetails()[3]!.weightEquation, "60");
|
||||
});
|
||||
|
||||
test('Add new PlanDetail', () async {
|
||||
@@ -127,16 +127,16 @@ main() {
|
||||
|
||||
await _exercisePlanRepository.saveExercisePlan();
|
||||
|
||||
expect(_exercisePlanRepository.getExercisePlan().name, "Test Plan2");
|
||||
expect(Cache().getMyExercisePlanDetails()[5].weightEquation, "105");
|
||||
expect(Cache().getMyExercisePlanDetails()[5].repeats, 6);
|
||||
expect(_exercisePlanRepository.getExercisePlan()!.name, "Test Plan2");
|
||||
expect(Cache().getMyExercisePlanDetails()[5]!.weightEquation, "105");
|
||||
expect(Cache().getMyExercisePlanDetails()[5]!.repeats, 6);
|
||||
});
|
||||
|
||||
test('Delete from PlanDetails', () async {
|
||||
_exercisePlanRepository.removeExerciseTypeFromPlanByExerciseTypeId(4);
|
||||
_exercisePlanRepository.saveExercisePlan();
|
||||
|
||||
expect(_exercisePlanRepository.exercisePlanDetails[4].change, ModelChange.delete);
|
||||
expect(_exercisePlanRepository.exercisePlanDetails[4]!.change, ModelChange.delete);
|
||||
expect(Cache().getMyExercisePlanDetails()[4], isNull);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:aitrainer_app/service/exercise_plan_service.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
main() {
|
||||
|
||||
setUp(() {
|
||||
Cache().setTestBaseUrl();
|
||||
});
|
||||
@@ -14,24 +13,18 @@ main() {
|
||||
test('add new plan and plan details', () async {
|
||||
final client = ExercisePlanApi();
|
||||
|
||||
ExercisePlan exercisePlan = ExercisePlan(
|
||||
"Test plan " + DateTime.now().toIso8601String(),
|
||||
62
|
||||
);
|
||||
ExercisePlan exercisePlan = ExercisePlan("Test plan " + DateTime.now().toIso8601String(), 62);
|
||||
exercisePlan.dateAdd = DateTime.now();
|
||||
|
||||
ExercisePlan savedPlan = await client.saveExercisePlan(exercisePlan);
|
||||
expect(savedPlan.name.substring(0, 9), "Test plan");
|
||||
expect(savedPlan.customerId, 62);
|
||||
|
||||
|
||||
|
||||
int newPlanId = savedPlan.exercisePlanId;
|
||||
int newPlanId = savedPlan.exercisePlanId!;
|
||||
//savedPlan.exercisePlanId = newPlanId;
|
||||
|
||||
ExercisePlanDetail detail = ExercisePlanDetail(
|
||||
39 //exerciseTypeId
|
||||
);
|
||||
ExercisePlanDetail detail = ExercisePlanDetail(39 //exerciseTypeId
|
||||
);
|
||||
detail.serie = 3;
|
||||
detail.repeats = 12;
|
||||
detail.weightEquation = "90";
|
||||
@@ -43,30 +36,28 @@ main() {
|
||||
expect(savedDetail.repeats, 12);
|
||||
expect(savedDetail.exercisePlanId, newPlanId);
|
||||
|
||||
await client.deleteExercisePlanDetail(savedDetail.exercisePlanDetailId);
|
||||
await client.deleteExercisePlan(savedPlan.exercisePlanId);
|
||||
|
||||
await client.deleteExercisePlanDetail(savedDetail.exercisePlanDetailId!);
|
||||
await client.deleteExercisePlan(savedPlan.exercisePlanId!);
|
||||
});
|
||||
});
|
||||
|
||||
test('get the last plan and change plan details', () async {
|
||||
final client = ExercisePlanApi();
|
||||
|
||||
ExercisePlan exercisePlan = await client.getLastExercisePlan(61);
|
||||
List<ExercisePlanDetail> list = await client.getExercisePlanDetail(exercisePlan.exercisePlanId);
|
||||
ExercisePlan? exercisePlan = await client.getLastExercisePlan(61);
|
||||
List<ExercisePlanDetail> list = await client.getExercisePlanDetail(exercisePlan!.exercisePlanId!);
|
||||
|
||||
expect(list.length, 2);
|
||||
ExercisePlanDetail detail = ExercisePlanDetail(3);
|
||||
detail.serie = 4;
|
||||
detail.repeats = 12;
|
||||
detail.weightEquation = "10";
|
||||
detail.exercisePlanId = exercisePlan.exercisePlanId;
|
||||
detail.exercisePlanId = exercisePlan.exercisePlanId!;
|
||||
//list.add(detail);
|
||||
ExercisePlanDetail newObjectToSave = await client.saveExercisePlanDetail(detail);
|
||||
List<ExercisePlanDetail> list2 = await client.getExercisePlanDetail(exercisePlan.exercisePlanId);
|
||||
List<ExercisePlanDetail> list2 = await client.getExercisePlanDetail(exercisePlan.exercisePlanId!);
|
||||
expect(list2.length, 3);
|
||||
expect(list2.last.weightEquation, "10");
|
||||
await client.deleteExercisePlanDetail(newObjectToSave.exercisePlanDetailId);
|
||||
|
||||
await client.deleteExercisePlanDetail(newObjectToSave.exercisePlanDetailId!);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+23
-23
@@ -16,8 +16,8 @@ class MockExercisePlanApi extends Mock implements ExercisePlanApi {
|
||||
|
||||
MockExercisePlanApi._internal();
|
||||
|
||||
final List<ExercisePlan> memoryExercisePlan = List();
|
||||
final List<ExercisePlanDetail> memoryExercisePlanDetail = List();
|
||||
final List<ExercisePlan> memoryExercisePlan = [];
|
||||
final List<ExercisePlanDetail> memoryExercisePlanDetail = [];
|
||||
|
||||
Future<ExercisePlan> saveExercisePlan(ExercisePlan plan) async {
|
||||
memoryExercisePlan.add(plan);
|
||||
@@ -32,14 +32,14 @@ class MockExercisePlanApi extends Mock implements ExercisePlanApi {
|
||||
}
|
||||
|
||||
Future<ExercisePlanDetail> updateExercisePlanDetail(ExercisePlanDetail detail, int planDetailId) async {
|
||||
ExercisePlanDetail updated;
|
||||
ExercisePlanDetail? updated;
|
||||
memoryExercisePlanDetail.forEach((element) {
|
||||
if (element.exercisePlanDetailId == planDetailId) {
|
||||
element = detail;
|
||||
}
|
||||
});
|
||||
|
||||
return updated;
|
||||
return updated!;
|
||||
}
|
||||
|
||||
Future<void> deleteExercisePlanDetail(int exercisePlanId) async {
|
||||
@@ -57,7 +57,7 @@ class MockExercisePlanApi extends Mock implements ExercisePlanApi {
|
||||
}
|
||||
|
||||
Future<List<ExercisePlanDetail>> getExercisePlanDetail(int exercisePlanId) async {
|
||||
List<ExercisePlanDetail> foundList = List();
|
||||
List<ExercisePlanDetail> foundList = [];
|
||||
memoryExercisePlanDetail.forEach((element) {
|
||||
if (element.exercisePlanId == exercisePlanId) {
|
||||
foundList.add(element);
|
||||
@@ -66,8 +66,8 @@ class MockExercisePlanApi extends Mock implements ExercisePlanApi {
|
||||
return foundList;
|
||||
}
|
||||
|
||||
Future<ExercisePlan> getLastExercisePlan(int customerId) async {
|
||||
ExercisePlan found;
|
||||
Future<ExercisePlan?> getLastExercisePlan(int customerId) async {
|
||||
ExercisePlan? found;
|
||||
memoryExercisePlan.forEach((element) {
|
||||
if (element.customerId == customerId) {
|
||||
found = element;
|
||||
@@ -80,20 +80,20 @@ class MockExercisePlanApi extends Mock implements ExercisePlanApi {
|
||||
class SimExercisePlanRepository with ExercisePlanRepository {
|
||||
Future<void> getExercisePlanDetails() async {
|
||||
if (exercisePlan == null) {
|
||||
ExercisePlan exercisePlan = await this.getLastExercisePlan();
|
||||
ExercisePlan? exercisePlan = await this.getLastExercisePlan();
|
||||
if (exercisePlan == null) {
|
||||
exercisePlanDetails = LinkedHashMap<int, ExercisePlanDetail>();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
List<ExercisePlanDetail> list = List();
|
||||
List<ExercisePlanDetail> list = [];
|
||||
LinkedHashMap<int, ExercisePlanDetail> listCache = Cache().getMyExercisePlanDetails();
|
||||
if (listCache.length > 0) {
|
||||
exercisePlanDetails = listCache;
|
||||
return;
|
||||
} else {
|
||||
list = await MockExercisePlanApi().getExercisePlanDetail(exercisePlan.exercisePlanId);
|
||||
list = await MockExercisePlanApi().getExercisePlanDetail(exercisePlan!.exercisePlanId!);
|
||||
}
|
||||
|
||||
exercisePlanDetails = LinkedHashMap<int, ExercisePlanDetail>();
|
||||
@@ -108,11 +108,11 @@ class SimExercisePlanRepository with ExercisePlanRepository {
|
||||
return;
|
||||
}
|
||||
|
||||
Future<ExercisePlan> getLastExercisePlan() async {
|
||||
Future<ExercisePlan?> getLastExercisePlan() async {
|
||||
if (customerId == 0) {
|
||||
return null;
|
||||
}
|
||||
ExercisePlan myExercisePlan = Cache().getMyExercisePlan();
|
||||
ExercisePlan? myExercisePlan = Cache().getMyExercisePlan();
|
||||
if (myExercisePlan != null) {
|
||||
newPlan = false;
|
||||
return myExercisePlan;
|
||||
@@ -120,7 +120,7 @@ class SimExercisePlanRepository with ExercisePlanRepository {
|
||||
|
||||
exercisePlan = await MockExercisePlanApi().getLastExercisePlan(customerId);
|
||||
newPlan = (exercisePlan == null);
|
||||
Cache().setMyExercisePlan(exercisePlan);
|
||||
Cache().setMyExercisePlan(exercisePlan!);
|
||||
return exercisePlan;
|
||||
}
|
||||
|
||||
@@ -131,23 +131,23 @@ class SimExercisePlanRepository with ExercisePlanRepository {
|
||||
}
|
||||
|
||||
String exercisePlanName;
|
||||
if (this.customerId == Cache().userLoggedIn.customerId) {
|
||||
exercisePlanName = Cache().userLoggedIn.name + " private";
|
||||
if (this.customerId == Cache().userLoggedIn!.customerId) {
|
||||
exercisePlanName = Cache().userLoggedIn!.name! + " private";
|
||||
} else {
|
||||
exercisePlanName = Cache().getTrainee().name + " " + Cache().getTrainee().firstname + " private";
|
||||
exercisePlanName = Cache().getTrainee()!.name! + " " + Cache().getTrainee()!.firstname! + " private";
|
||||
}
|
||||
|
||||
exercisePlan = ExercisePlan(exercisePlanName, this.customerId);
|
||||
}
|
||||
if (newPlan) {
|
||||
exercisePlan.dateAdd = DateTime.now();
|
||||
exercisePlan.private = true;
|
||||
exercisePlan!.dateAdd = DateTime.now();
|
||||
exercisePlan!.private = true;
|
||||
|
||||
ExercisePlan savedExercisePlan = await MockExercisePlanApi().saveExercisePlan(exercisePlan);
|
||||
ExercisePlan savedExercisePlan = await MockExercisePlanApi().saveExercisePlan(exercisePlan!);
|
||||
|
||||
LinkedHashMap<int, ExercisePlanDetail> savedExercisePlanDetails = LinkedHashMap();
|
||||
exercisePlanDetails.forEach((exerciseTypeId, exercisePlanDetail) async {
|
||||
exercisePlanDetail.exercisePlanId = savedExercisePlan.exercisePlanId;
|
||||
exercisePlanDetail.exercisePlanId = savedExercisePlan.exercisePlanId!;
|
||||
|
||||
ExercisePlanDetail savedDetail = await MockExercisePlanApi().saveExercisePlanDetail(exercisePlanDetail);
|
||||
|
||||
@@ -156,14 +156,14 @@ class SimExercisePlanRepository with ExercisePlanRepository {
|
||||
|
||||
exercisePlan = savedExercisePlan;
|
||||
} else {
|
||||
await MockExercisePlanApi().updateExercisePlan(exercisePlan, exercisePlan.exercisePlanId);
|
||||
await MockExercisePlanApi().updateExercisePlan(exercisePlan!, exercisePlan!.exercisePlanId!);
|
||||
|
||||
exercisePlanDetails.forEach((exerciseTypeId, exercisePlanDetail) async {
|
||||
if (exercisePlanDetail.change == ModelChange.delete) {
|
||||
await MockExercisePlanApi().deleteExercisePlanDetail(exercisePlanDetail.exercisePlanDetailId);
|
||||
await MockExercisePlanApi().deleteExercisePlanDetail(exercisePlanDetail.exercisePlanDetailId!);
|
||||
Cache().deleteMyExercisePlanDetail(exercisePlanDetail);
|
||||
} else if (exercisePlanDetail.change == ModelChange.update) {
|
||||
await MockExercisePlanApi().updateExercisePlanDetail(exercisePlanDetail, exercisePlanDetail.exercisePlanDetailId);
|
||||
await MockExercisePlanApi().updateExercisePlanDetail(exercisePlanDetail, exercisePlanDetail.exercisePlanDetailId!);
|
||||
Cache().updateMyExercisePlanDetail(exercisePlanDetail);
|
||||
} else if (exercisePlanDetail.change == ModelChange.add) {
|
||||
await MockExercisePlanApi().saveExercisePlanDetail(exercisePlanDetail);
|
||||
|
||||
@@ -15,7 +15,7 @@ import 'package:aitrainer_app/util/common.dart';
|
||||
import 'package:aitrainer_app/view/login.dart';
|
||||
import 'package:bloc_test/bloc_test.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
|
||||
@@ -16,7 +16,7 @@ import 'package:aitrainer_app/util/common.dart';
|
||||
import 'package:aitrainer_app/view/login.dart';
|
||||
import 'package:bloc_test/bloc_test.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
@@ -41,23 +41,19 @@ class MockUserRepository extends Mock implements UserRepository {
|
||||
}
|
||||
}
|
||||
|
||||
class MockLoginBloc extends MockBloc<FormBlocEvent> implements LoginBloc {}
|
||||
|
||||
class MockCommon with Common {
|
||||
String getEmailError() {
|
||||
return EMAIL_ERROR;
|
||||
return emailError;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
group('LoginScreen', () {
|
||||
MockLoginBloc loginBloc;
|
||||
Widget loginWidget;
|
||||
MockCommon common;
|
||||
late Widget loginWidget;
|
||||
late MockCommon common;
|
||||
|
||||
setUp(() async {
|
||||
await DB().initDb();
|
||||
loginBloc = MockLoginBloc();
|
||||
common = MockCommon();
|
||||
|
||||
loginWidget = MaterialApp(home: LoginPage(), localizationsDelegates: [
|
||||
|
||||
Reference in New Issue
Block a user