dcm fix --only-rules=prefer-trailing-comma lib test test_data integration_test

This commit is contained in:
Dieter Plaetinck
2024-09-18 15:55:06 +03:00
parent a589d87fad
commit 66ced6ccc4
18 changed files with 284 additions and 237 deletions

View File

@@ -34,9 +34,9 @@ Widget createDashboardScreen({locale = 'en'}) {
'date': '2022-12-01',
'impression': '3',
'time_start': '17:00',
'time_end': '19:00'
}
]
'time_end': '19:00',
},
],
};
when(mockWorkoutProvider.fetchSessionData()).thenAnswer((a) => Future.value(logs));

View File

@@ -36,9 +36,7 @@ Widget createWeightScreen({locale = 'en'}) {
supportedLocales: AppLocalizations.supportedLocales,
theme: wgerLightTheme,
home: const WeightScreen(),
routes: {
FormScreen.routeName: (ctx) => const FormScreen(),
},
routes: {FormScreen.routeName: (ctx) => const FormScreen()},
),
);
}

View File

@@ -57,7 +57,7 @@ const languages = [
'ru-RU',
'tr-TR',
'uk',
'zh-CN'
'zh-CN',
];
void main() {

View File

@@ -35,10 +35,11 @@ void main() {
return ChangeNotifierProvider<ExercisesProvider>(
create: (context) => mockExerciseProvider,
child: MaterialApp(
locale: Locale(locale),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: const SettingsPage()),
locale: Locale(locale),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: const SettingsPage(),
),
);
}

View File

@@ -114,7 +114,7 @@ void main() {
'1f5d2b2f-d4ea-4eeb-9377-56176465e08d',
'ab645585-26ef-4992-a9ec-15425687ece9',
'd8aa5990-bb47-4111-9823-e2fbd98fe07f',
'49a159e1-1e00-409a-81c9-b4d4489fbd67'
'49a159e1-1e00-409a-81c9-b4d4489fbd67',
]);
expect(exercise.videos.map((v) => v.uuid), ['63e996e9-a772-4ca5-9d09-8b4be03f6be4']);

View File

@@ -57,7 +57,7 @@ void main() {
'1f5d2b2f-d4ea-4eeb-9377-56176465e08d',
'ab645585-26ef-4992-a9ec-15425687ece9',
'd8aa5990-bb47-4111-9823-e2fbd98fe07f',
'49a159e1-1e00-409a-81c9-b4d4489fbd67'
'49a159e1-1e00-409a-81c9-b4d4489fbd67',
]);
expect(exercise.videos.map((v) => v.uuid), ['63e996e9-a772-4ca5-9d09-8b4be03f6be4']);

View File

@@ -34,13 +34,14 @@ void main() {
Uri.https('localhost', 'api/v2/gallery/'),
headers: anyNamed('headers'),
)).thenAnswer((_) async => http.Response(
'{"count":1,"next":null,"previous":null,"results":['
'{"id":58,'
'"date":"2022-01-09",'
'"image":"https://wger.de/media/gallery/170335/d2b9c9e0-d541-41ae-8786-a2ab459e3538.jpg",'
'"description":"eggsaddjujuit\'ddayhadIforcanview",'
'"height":1280,"width":960}]}',
200));
'{"count":1,"next":null,"previous":null,"results":['
'{"id":58,'
'"date":"2022-01-09",'
'"image":"https://wger.de/media/gallery/170335/d2b9c9e0-d541-41ae-8786-a2ab459e3538.jpg",'
'"description":"eggsaddjujuit\'ddayhadIforcanview",'
'"height":1280,"width":960}]}',
200,
));
final galleryProvider = GalleryProvider(testAuthProvider, [], client);
@@ -57,20 +58,22 @@ void main() {
Uri.https('localhost', 'api/v2/gallery/58/'),
headers: anyNamed('headers'),
)).thenAnswer((_) async => http.Response(
'{"id":58,'
'"date":"2022-01-09",'
'"image":"https://wger.de/media/gallery/170335/d2b9c9e0-d541-41ae-8786-a2ab459e3538.jpg",'
'"description":"eggsaddjujuit\'ddayhadIforcanview",'
'"height":1280,"width":960}',
200));
'{"id":58,'
'"date":"2022-01-09",'
'"image":"https://wger.de/media/gallery/170335/d2b9c9e0-d541-41ae-8786-a2ab459e3538.jpg",'
'"description":"eggsaddjujuit\'ddayhadIforcanview",'
'"height":1280,"width":960}',
200,
));
final galleryProvider = GalleryProvider(testAuthProvider, [], client);
final image = gallery.Image(
id: 58,
date: DateTime(2022, 01, 09),
url: 'https://wger.de/media/gallery/170335/d2b9c9e0-d541-41ae-8786-a2ab459e3538.jpg',
description: "eggsaddjujuit'ddayhadIforcanview");
id: 58,
date: DateTime(2022, 01, 09),
url: 'https://wger.de/media/gallery/170335/d2b9c9e0-d541-41ae-8786-a2ab459e3538.jpg',
description: "eggsaddjujuit'ddayhadIforcanview",
);
galleryProvider.images.add(image);

View File

@@ -11,7 +11,7 @@ void main() {
date: DateTime(2021, 7, 22),
value: 83,
notes: 'notes',
)
),
];
final MeasurementEntry tMeasurementEntry = MeasurementEntry(
@@ -35,7 +35,7 @@ void main() {
'category': 123,
'date': '2021-07-22',
'value': 83,
'notes': 'notes'
'notes': 'notes',
};
final Map<String, dynamic> tMeasurementCategoryMap = {

View File

@@ -47,7 +47,12 @@ void main() {
// act
final result = tMeasurementEntry.copyWith(
id: 83, category: 17, date: DateTime(1960), value: 93, notes: 'Interesting');
id: 83,
category: 17,
date: DateTime(1960),
value: 93,
notes: 'Interesting',
);
// assert
expect(result, tMeasurementEntryCopied);

View File

@@ -38,7 +38,7 @@ void main() {
MeasurementCategory(id: 1, name: 'Strength', unit: 'kN');
final List<MeasurementCategory> tMeasurementCategories = [
const MeasurementCategory(id: 1, name: 'Strength', unit: 'kN'),
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'),
];
final Map<String, dynamic> tMeasurementCategoriesMap =
jsonDecode(fixture('measurement/measurement_categories.json'));
@@ -158,9 +158,9 @@ void main() {
date: DateTime(2021, 7, 10),
value: 15.00,
notes: '',
)
),
]),
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'),
];
// act
@@ -197,17 +197,18 @@ void main() {
});
test(
'should add the result from the post call to the categories List and sort the list by alphabetical order',
() async {
// arrange
await measurementProvider.fetchAndSetCategories();
'should add the result from the post call to the categories List and sort the list by alphabetical order',
() async {
// arrange
await measurementProvider.fetchAndSetCategories();
// act
await measurementProvider.addCategory(tMeasurementCategoryWithoutId);
// act
await measurementProvider.addCategory(tMeasurementCategoryWithoutId);
// assert
expect(measurementProvider.categories, tMeasurementCategoriesAdded);
});
// assert
expect(measurementProvider.categories, tMeasurementCategoriesAdded);
},
);
});
group('deleteCategory()', () {
@@ -215,23 +216,24 @@ void main() {
await measurementProvider.fetchAndSetCategories();
});
test(
'should remove a MeasurementCategory from the categories list for an id and call the api to remove the MeasurementCategory',
() async {
// arrange
when(mockWgerBaseProvider.deleteRequest(any, any))
.thenAnswer((realInvocation) => Future.value(Response('', 200)));
'should remove a MeasurementCategory from the categories list for an id and call the api to remove the MeasurementCategory',
() async {
// arrange
when(mockWgerBaseProvider.deleteRequest(any, any))
.thenAnswer((realInvocation) => Future.value(Response('', 200)));
final List<MeasurementCategory> tMeasurementCategoriesOneDeleted = [
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
];
final List<MeasurementCategory> tMeasurementCategoriesOneDeleted = [
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'),
];
// act
await measurementProvider.deleteCategory(tCategoryId);
// act
await measurementProvider.deleteCategory(tCategoryId);
// assert
verify(mockWgerBaseProvider.deleteRequest('measurement-category', tCategoryId));
expect(measurementProvider.categories, tMeasurementCategoriesOneDeleted);
});
// assert
verify(mockWgerBaseProvider.deleteRequest('measurement-category', tCategoryId));
expect(measurementProvider.categories, tMeasurementCategoriesOneDeleted);
},
);
test('should throw a NoSuchEntryException if no category is found', () {
// act & assert
@@ -239,16 +241,19 @@ void main() {
});
test(
'should re-add the "removed" MeasurementCategory and relay the exception on WgerHttpException',
() {
// arrange
when(mockWgerBaseProvider.deleteRequest(any, any)).thenThrow(WgerHttpException('{}'));
'should re-add the "removed" MeasurementCategory and relay the exception on WgerHttpException',
() {
// arrange
when(mockWgerBaseProvider.deleteRequest(any, any)).thenThrow(WgerHttpException('{}'));
// act & assert
expect(
() => measurementProvider.deleteCategory(tCategoryId), throwsA(isA<WgerHttpException>()));
expect(measurementProvider.categories, tMeasurementCategories);
});
// act & assert
expect(
() => measurementProvider.deleteCategory(tCategoryId),
throwsA(isA<WgerHttpException>()),
);
expect(measurementProvider.categories, tMeasurementCategories);
},
);
});
group('editCategory()', () {
@@ -279,8 +284,10 @@ void main() {
test("should throw a NoSuchEntryException if category doesn't exist", () {
// act & assert
expect(() => measurementProvider.editCategory(83, tCategoryEditedName, tCategoryEditedUnit),
throwsA(isA<NoSuchEntryException>()));
expect(
() => measurementProvider.editCategory(83, tCategoryEditedName, tCategoryEditedUnit),
throwsA(isA<NoSuchEntryException>()),
);
});
test('should call api to patch the category', () async {
@@ -297,9 +304,13 @@ void main() {
// act & assert
expect(
() => measurementProvider.editCategory(
tCategoryId, tCategoryEditedName, tCategoryEditedUnit),
throwsA(isA<WgerHttpException>()));
() => measurementProvider.editCategory(
tCategoryId,
tCategoryEditedName,
tCategoryEditedUnit,
),
throwsA(isA<WgerHttpException>()),
);
expect(measurementProvider.categories, tMeasurementCategories);
});
});
@@ -337,9 +348,9 @@ void main() {
value: 15.00,
notes: '',
),
tMeasurementEntry
tMeasurementEntry,
]),
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'),
];
setUp(() async {
@@ -372,17 +383,18 @@ void main() {
});
test(
"should add MeasurementEntry to its MeasurementCategory in the categories List and sort the category's list by date",
() async {
// arrange
await measurementProvider.fetchAndSetCategoryEntries(tCategoryId);
"should add MeasurementEntry to its MeasurementCategory in the categories List and sort the category's list by date",
() async {
// arrange
await measurementProvider.fetchAndSetCategoryEntries(tCategoryId);
// act
await measurementProvider.addEntry(tMeasurementEntryWithoutId);
// act
await measurementProvider.addEntry(tMeasurementEntryWithoutId);
// assert
expect(measurementProvider.categories, tMeasurementCategories);
});
// assert
expect(measurementProvider.categories, tMeasurementCategories);
},
);
test('should throw a NoSuchEntryException if no category is found', () {
// arrange
@@ -399,8 +411,10 @@ void main() {
.thenAnswer((realInvocation) => Future.value(measurementEntryMapWrongCategory));
// act & assert
expect(() => measurementProvider.addEntry(tMeasurementEntryWrongCategory),
throwsA(isA<NoSuchEntryException>()));
expect(
() => measurementProvider.addEntry(tMeasurementEntryWrongCategory),
throwsA(isA<NoSuchEntryException>()),
);
});
});
@@ -416,7 +430,7 @@ void main() {
notes: 'Some important notes',
),
]),
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'),
];
setUp(() async {
@@ -437,17 +451,22 @@ void main() {
test("should throw a NoSuchEntryException if the category isn't found", () {
// act & assert
expect(() => measurementProvider.deleteEntry(tEntryId, 83),
throwsA(isA<NoSuchEntryException>()));
expect(
() => measurementProvider.deleteEntry(tEntryId, 83),
throwsA(isA<NoSuchEntryException>()),
);
});
test(
"should throw a NoSuchEntryException if the entry in the categories entries List isn't found",
() {
// act & assert
expect(() => measurementProvider.deleteEntry(83, tCategoryId),
throwsA(isA<NoSuchEntryException>()));
});
"should throw a NoSuchEntryException if the entry in the categories entries List isn't found",
() {
// act & assert
expect(
() => measurementProvider.deleteEntry(83, tCategoryId),
throwsA(isA<NoSuchEntryException>()),
);
},
);
test('should call the api to remove the MeasurementEntry', () async {
// act
@@ -458,35 +477,38 @@ void main() {
});
test(
'should re-add the "removed" MeasurementEntry and throw a WgerHttpException if the api call fails',
() {
// arrange
final List<MeasurementCategory> tMeasurementCategories = [
MeasurementCategory(id: 1, name: 'Strength', unit: 'kN', entries: [
MeasurementEntry(
id: 1,
category: 1,
date: DateTime(2021, 7, 21),
value: 10,
notes: 'Some important notes',
),
MeasurementEntry(
id: 2,
category: 1,
date: DateTime(2021, 7, 10),
value: 15.00,
notes: '',
),
]),
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
];
when(mockWgerBaseProvider.deleteRequest(any, any)).thenThrow(WgerHttpException('{}'));
'should re-add the "removed" MeasurementEntry and throw a WgerHttpException if the api call fails',
() {
// arrange
final List<MeasurementCategory> tMeasurementCategories = [
MeasurementCategory(id: 1, name: 'Strength', unit: 'kN', entries: [
MeasurementEntry(
id: 1,
category: 1,
date: DateTime(2021, 7, 21),
value: 10,
notes: 'Some important notes',
),
MeasurementEntry(
id: 2,
category: 1,
date: DateTime(2021, 7, 10),
value: 15.00,
notes: '',
),
]),
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'),
];
when(mockWgerBaseProvider.deleteRequest(any, any)).thenThrow(WgerHttpException('{}'));
// act & assert
expect(() => measurementProvider.deleteEntry(tEntryId, tCategoryId),
throwsA(isA<WgerHttpException>()));
expect(measurementProvider.categories, tMeasurementCategories);
});
// act & assert
expect(
() => measurementProvider.deleteEntry(tEntryId, tCategoryId),
throwsA(isA<WgerHttpException>()),
);
expect(measurementProvider.categories, tMeasurementCategories);
},
);
});
group('editEntry()', () {
@@ -525,9 +547,9 @@ void main() {
date: DateTime(2021, 7, 10),
value: 15.00,
notes: '',
)
),
]),
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm')
const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'),
];
// act
@@ -546,27 +568,29 @@ void main() {
test("should throw a NoSuchEntryException if category doesn't exist", () {
// act & assert
expect(
() => measurementProvider.editEntry(
tEntryId,
83,
tEntryEditedValue,
tEntryEditedNote,
tEntryEditedDate,
),
throwsA(isA<NoSuchEntryException>()));
() => measurementProvider.editEntry(
tEntryId,
83,
tEntryEditedValue,
tEntryEditedNote,
tEntryEditedDate,
),
throwsA(isA<NoSuchEntryException>()),
);
});
test("should throw a NoSuchEntryException if entry doesn't exist", () {
// act & assert
expect(
() => measurementProvider.editEntry(
83,
tCategoryId,
tEntryEditedValue,
tEntryEditedNote,
tEntryEditedDate,
),
throwsA(isA<NoSuchEntryException>()));
() => measurementProvider.editEntry(
83,
tCategoryId,
tEntryEditedValue,
tEntryEditedNote,
tEntryEditedDate,
),
throwsA(isA<NoSuchEntryException>()),
);
});
test('should call api to patch the entry', () async {

View File

@@ -81,12 +81,15 @@ void main() {
when(mockNutrition.searchIngredientWithCode('123')).thenAnswer((_) => Future.value(ingredient));
when(mockNutrition.searchIngredientWithCode('')).thenAnswer((_) => Future.value(null));
when(mockNutrition.searchIngredientWithCode('222')).thenAnswer((_) => Future.value(null));
when(mockNutrition.searchIngredient(any,
languageCode: anyNamed('languageCode'), searchEnglish: anyNamed('searchEnglish')))
.thenAnswer(
when(mockNutrition.searchIngredient(
any,
languageCode: anyNamed('languageCode'),
searchEnglish: anyNamed('searchEnglish'),
)).thenAnswer(
(_) => Future.value(
IngredientApiSearch.fromJson(json.decode(fixture('nutrition/ingredient_suggestions')))
.suggestions),
IngredientApiSearch.fromJson(json.decode(fixture('nutrition/ingredient_suggestions')))
.suggestions,
),
);
when(mockNutrition.addMealItem(any, meal1)).thenAnswer((_) => Future.value(mealItem));
@@ -280,7 +283,7 @@ void main() {
expect(find.text('Please enter a valid number'), findsOneWidget);
});
//TODO: isn't this test just a duplicate of the above one? can be removed?
//TODO: isn't this test just a duplicate of the above one? can be removed?
testWidgets('save ingredient with incorrect weight input type', (WidgetTester tester) async {
await tester.pumpWidget(createMealItemFormScreen(meal1, '123', true));
@@ -298,38 +301,40 @@ void main() {
expect(find.text('Please enter a valid number'), findsOneWidget);
});
testWidgets('save complete ingredient with correct weight input type',
(WidgetTester tester) async {
await tester.pumpWidget(createMealItemFormScreen(meal1, '123', true));
testWidgets(
'save complete ingredient with correct weight input type',
(WidgetTester tester) async {
await tester.pumpWidget(createMealItemFormScreen(meal1, '123', true));
final IngredientFormState formState = tester.state(find.byType(IngredientForm));
final IngredientFormState formState = tester.state(find.byType(IngredientForm));
await tester.tap(find.byKey(const Key('scan-button')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('scan-button')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('ingredient-scan-result-dialog')), findsOneWidget);
expect(find.byKey(const Key('ingredient-scan-result-dialog')), findsOneWidget);
await tester.tap(find.byKey(const Key('ingredient-scan-result-dialog-confirm-button')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('ingredient-scan-result-dialog-confirm-button')));
await tester.pumpAndSettle();
expect(formState.ingredientIdController.text, '1');
expect(formState.ingredientIdController.text, '1');
await tester.enterText(find.byKey(const Key('field-weight')), '2');
await tester.enterText(find.byKey(const Key('field-weight')), '2');
// once ID and weight are set, it'll fetchIngredient and show macros preview and ingredient image
when(mockNutrition.fetchIngredient(1)).thenAnswer((_) => Future.value(
Ingredient.fromJson(jsonDecode(fixture('nutrition/ingredientinfo_59887.json'))),
));
await mockNetworkImagesFor(() => tester.pumpAndSettle());
// once ID and weight are set, it'll fetchIngredient and show macros preview and ingredient image
when(mockNutrition.fetchIngredient(1)).thenAnswer((_) => Future.value(
Ingredient.fromJson(jsonDecode(fixture('nutrition/ingredientinfo_59887.json'))),
));
await mockNetworkImagesFor(() => tester.pumpAndSettle());
expect(find.byKey(const Key('ingredient-scan-result-dialog')), findsNothing);
expect(find.byKey(const Key('ingredient-scan-result-dialog')), findsNothing);
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
await tester.pumpAndSettle();
expect(formState.mealItem.amount, 2);
expect(formState.mealItem.amount, 2);
verify(mockNutrition.addMealItem(any, meal1));
});
verify(mockNutrition.addMealItem(any, meal1));
},
);
});
}

View File

@@ -33,65 +33,70 @@ void main() {
group('model tests', () {
test('Test NutritionalPlan.nutritionalGoals based on meals', () {
expect(
plan.nutritionalGoals,
NutritionalGoals(
energy: 4118.75,
protein: 32.75,
carbohydrates: 347.5,
carbohydratesSugar: 9.5,
fat: 59.0,
fatSaturated: 37.75,
fiber: 52.5,
sodium: 30.5));
plan.nutritionalGoals,
NutritionalGoals(
energy: 4118.75,
protein: 32.75,
carbohydrates: 347.5,
carbohydratesSugar: 9.5,
fat: 59.0,
fatSaturated: 37.75,
fiber: 52.5,
sodium: 30.5,
),
);
});
test('Test NutritionalPlan.nutritionalValues based on 3 macros and energy', () {
expect(
NutritionalPlan(
description: '3 macros and energy defined',
creationDate: DateTime(2024, 5, 4),
goalProtein: 150,
goalCarbohydrates: 100,
goalFat: 100,
goalEnergy: 1500,
).nutritionalGoals,
NutritionalGoals(
energy: 1500,
protein: 150,
carbohydrates: 100,
fat: 100,
));
NutritionalPlan(
description: '3 macros and energy defined',
creationDate: DateTime(2024, 5, 4),
goalProtein: 150,
goalCarbohydrates: 100,
goalFat: 100,
goalEnergy: 1500,
).nutritionalGoals,
NutritionalGoals(
energy: 1500,
protein: 150,
carbohydrates: 100,
fat: 100,
),
);
});
test('Test NutritionalPlan.nutritionalValues based on 2 macros and energy', () {
expect(
NutritionalPlan(
description: '2 macros and energy defined',
creationDate: DateTime(2024, 5, 4),
goalProtein: 100,
goalCarbohydrates: 100,
goalEnergy: 1700,
).nutritionalGoals,
NutritionalGoals(
energy: 1700,
protein: 100,
carbohydrates: 100,
fat: 100, // inferred
));
NutritionalPlan(
description: '2 macros and energy defined',
creationDate: DateTime(2024, 5, 4),
goalProtein: 100,
goalCarbohydrates: 100,
goalEnergy: 1700,
).nutritionalGoals,
NutritionalGoals(
energy: 1700,
protein: 100,
carbohydrates: 100,
fat: 100, // inferred
),
);
});
test('Test NutritionalPlan.nutritionalValues based on 3 macros only', () {
expect(
NutritionalPlan(
description: '3 macros defined',
creationDate: DateTime(2024, 5, 4),
goalProtein: 100,
goalCarbohydrates: 100,
goalFat: 10,
).nutritionalGoals,
NutritionalGoals(
energy: 890, // inferred
protein: 100,
carbohydrates: 100,
fat: 10,
));
NutritionalPlan(
description: '3 macros defined',
creationDate: DateTime(2024, 5, 4),
goalProtein: 100,
goalCarbohydrates: 100,
goalFat: 10,
).nutritionalGoals,
NutritionalGoals(
energy: 890, // inferred
protein: 100,
carbohydrates: 100,
fat: 10,
),
);
});
test('Test the nutritionalValues method for meals', () {

View File

@@ -93,14 +93,15 @@ void main() {
);
when(mockBaseProvider.makeUrl(any, query: anyNamed('query'))).thenReturn(uri);
when(mockBaseProvider.deleteRequest('weightentry', 4)).thenAnswer(
(_) => Future.value(Response("{'id': 4, 'date': '2021-01-01', 'weight': '80'}", 204)));
(_) => Future.value(Response("{'id': 4, 'date': '2021-01-01', 'weight': '80'}", 204)),
);
// DELETE the data from the server
final BodyWeightProvider provider = BodyWeightProvider(mockBaseProvider);
provider.items = [
WeightEntry(id: 4, weight: 80, date: DateTime(2021, 1, 1)),
WeightEntry(id: 2, weight: 100, date: DateTime(2021, 2, 2)),
WeightEntry(id: 5, weight: 60, date: DateTime(2021, 2, 2))
WeightEntry(id: 5, weight: 60, date: DateTime(2021, 2, 2)),
];
await provider.deleteEntry(4);

View File

@@ -133,7 +133,11 @@ void main() {
testWidgets('Test creating a new workout - name and description', (WidgetTester tester) async {
final editWorkout = WorkoutPlan(
id: 2, creationDate: newPlan.creationDate, name: 'My workout', description: 'Get yuuuge');
id: 2,
creationDate: newPlan.creationDate,
name: 'My workout',
description: 'Get yuuuge',
);
when(mockWorkoutPlans.addWorkout(any)).thenAnswer((_) => Future.value(editWorkout));
await tester.pumpWidget(createHomeScreen(newPlan));

View File

@@ -58,7 +58,7 @@ void main() {
'id': 325397,
'name': 'Test workout',
'creation_date': '2022-10-10',
'description': 'Test workout abcd'
'description': 'Test workout abcd',
}),
);
@@ -85,7 +85,7 @@ void main() {
'id': 325397,
'name': 'Test workout',
'creation_date': '2022-10-10',
'description': 'Test workout abcd'
'description': 'Test workout abcd',
}),
);
when(mockBaseProvider.deleteRequest('workout', 325397)).thenAnswer(

View File

@@ -57,16 +57,17 @@ void main() {
[workoutPlan],
),
child: ChangeNotifierProvider<ExercisesProvider>(
create: (context) => mockExerciseProvider,
child: MaterialApp(
locale: Locale(locale),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
navigatorKey: GlobalKey<NavigatorState>(),
home: Scaffold(
body: SetFormWidget(day),
),
)),
create: (context) => mockExerciseProvider,
child: MaterialApp(
locale: Locale(locale),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
navigatorKey: GlobalKey<NavigatorState>(),
home: Scaffold(
body: SetFormWidget(day),
),
),
),
);
}

View File

@@ -47,6 +47,6 @@ List<gallery.Image> getTestImages() {
'https://raw.githubusercontent.com/wger-project/flutter/master/fastlane/metadata/android/en-US/images/phoneScreenshots/06%20-%20weight.png',
description: '',
date: DateTime(2021, 2, 22),
)
),
];
}

View File

@@ -202,7 +202,7 @@ final squatsTranslations = [
squatsEN,
squatsEL,
squatsAR,
squatsZH
squatsZH,
];
final benchPressDE = Translation(
@@ -492,7 +492,7 @@ final crunchesTranslations = [
crunchesRU,
crunchesHE,
crunchesAR,
crunchesZH
crunchesZH,
];
final curlsEN = Translation(