From 66ced6ccc434042cfc294554adc27d524269056c Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 18 Sep 2024 15:55:06 +0300 Subject: [PATCH] dcm fix --only-rules=prefer-trailing-comma lib test test_data integration_test --- integration_test/1_dashboard.dart | 6 +- integration_test/6_weight.dart | 4 +- integration_test/make_screenshots_test.dart | 2 +- test/core/settings_test.dart | 9 +- .../exercise_provider_load_test.dart | 2 +- test/exercises/model_exercise_test.dart | 2 +- test/gallery/gallery_provider_test.dart | 37 +-- .../measurement_category_test.dart | 4 +- test/measurements/measurement_entry_test.dart | 7 +- .../measurement_provider_test.dart | 240 ++++++++++-------- .../nutritional_meal_item_form_test.dart | 61 +++-- .../nutritional_plan_model_test.dart | 105 ++++---- test/weight/weight_provider_test.dart | 5 +- test/workout/workout_form_test.dart | 6 +- test/workout/workout_provider_test.dart | 4 +- test/workout/workout_set_form_test.dart | 21 +- test_data/gallery.dart | 2 +- test_data/screenshots_exercises.dart | 4 +- 18 files changed, 284 insertions(+), 237 deletions(-) diff --git a/integration_test/1_dashboard.dart b/integration_test/1_dashboard.dart index b59a7be6..4550fea7 100644 --- a/integration_test/1_dashboard.dart +++ b/integration_test/1_dashboard.dart @@ -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)); diff --git a/integration_test/6_weight.dart b/integration_test/6_weight.dart index 6da0995d..57f46609 100644 --- a/integration_test/6_weight.dart +++ b/integration_test/6_weight.dart @@ -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()}, ), ); } diff --git a/integration_test/make_screenshots_test.dart b/integration_test/make_screenshots_test.dart index c197d769..78ce1222 100644 --- a/integration_test/make_screenshots_test.dart +++ b/integration_test/make_screenshots_test.dart @@ -57,7 +57,7 @@ const languages = [ 'ru-RU', 'tr-TR', 'uk', - 'zh-CN' + 'zh-CN', ]; void main() { diff --git a/test/core/settings_test.dart b/test/core/settings_test.dart index 213fae58..1b2fa453 100644 --- a/test/core/settings_test.dart +++ b/test/core/settings_test.dart @@ -35,10 +35,11 @@ void main() { return ChangeNotifierProvider( 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(), + ), ); } diff --git a/test/exercises/exercise_provider_load_test.dart b/test/exercises/exercise_provider_load_test.dart index b12f1a59..bc809b5c 100644 --- a/test/exercises/exercise_provider_load_test.dart +++ b/test/exercises/exercise_provider_load_test.dart @@ -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']); diff --git a/test/exercises/model_exercise_test.dart b/test/exercises/model_exercise_test.dart index 72e7f899..2d817ba0 100644 --- a/test/exercises/model_exercise_test.dart +++ b/test/exercises/model_exercise_test.dart @@ -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']); diff --git a/test/gallery/gallery_provider_test.dart b/test/gallery/gallery_provider_test.dart index a7b20a80..b0e067b6 100644 --- a/test/gallery/gallery_provider_test.dart +++ b/test/gallery/gallery_provider_test.dart @@ -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); diff --git a/test/measurements/measurement_category_test.dart b/test/measurements/measurement_category_test.dart index 0f66a73e..21009d0e 100644 --- a/test/measurements/measurement_category_test.dart +++ b/test/measurements/measurement_category_test.dart @@ -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 tMeasurementCategoryMap = { diff --git a/test/measurements/measurement_entry_test.dart b/test/measurements/measurement_entry_test.dart index 8c535b06..7e972fe0 100644 --- a/test/measurements/measurement_entry_test.dart +++ b/test/measurements/measurement_entry_test.dart @@ -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); diff --git a/test/measurements/measurement_provider_test.dart b/test/measurements/measurement_provider_test.dart index ea176ac8..90f60bc1 100644 --- a/test/measurements/measurement_provider_test.dart +++ b/test/measurements/measurement_provider_test.dart @@ -38,7 +38,7 @@ void main() { MeasurementCategory(id: 1, name: 'Strength', unit: 'kN'); final List 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 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 tMeasurementCategoriesOneDeleted = [ - const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm') - ]; + final List 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())); - expect(measurementProvider.categories, tMeasurementCategories); - }); + // act & assert + expect( + () => measurementProvider.deleteCategory(tCategoryId), + throwsA(isA()), + ); + 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())); + expect( + () => measurementProvider.editCategory(83, tCategoryEditedName, tCategoryEditedUnit), + throwsA(isA()), + ); }); 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())); + () => measurementProvider.editCategory( + tCategoryId, + tCategoryEditedName, + tCategoryEditedUnit, + ), + throwsA(isA()), + ); 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())); + expect( + () => measurementProvider.addEntry(tMeasurementEntryWrongCategory), + throwsA(isA()), + ); }); }); @@ -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())); + expect( + () => measurementProvider.deleteEntry(tEntryId, 83), + throwsA(isA()), + ); }); 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())); - }); + "should throw a NoSuchEntryException if the entry in the categories entries List isn't found", + () { + // act & assert + expect( + () => measurementProvider.deleteEntry(83, tCategoryId), + throwsA(isA()), + ); + }, + ); 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 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 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())); - expect(measurementProvider.categories, tMeasurementCategories); - }); + // act & assert + expect( + () => measurementProvider.deleteEntry(tEntryId, tCategoryId), + throwsA(isA()), + ); + 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())); + () => measurementProvider.editEntry( + tEntryId, + 83, + tEntryEditedValue, + tEntryEditedNote, + tEntryEditedDate, + ), + throwsA(isA()), + ); }); test("should throw a NoSuchEntryException if entry doesn't exist", () { // act & assert expect( - () => measurementProvider.editEntry( - 83, - tCategoryId, - tEntryEditedValue, - tEntryEditedNote, - tEntryEditedDate, - ), - throwsA(isA())); + () => measurementProvider.editEntry( + 83, + tCategoryId, + tEntryEditedValue, + tEntryEditedNote, + tEntryEditedDate, + ), + throwsA(isA()), + ); }); test('should call api to patch the entry', () async { diff --git a/test/nutrition/nutritional_meal_item_form_test.dart b/test/nutrition/nutritional_meal_item_form_test.dart index ba5de3f0..fddca2b3 100644 --- a/test/nutrition/nutritional_meal_item_form_test.dart +++ b/test/nutrition/nutritional_meal_item_form_test.dart @@ -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)); + }, + ); }); } diff --git a/test/nutrition/nutritional_plan_model_test.dart b/test/nutrition/nutritional_plan_model_test.dart index a48fa468..ac35a162 100644 --- a/test/nutrition/nutritional_plan_model_test.dart +++ b/test/nutrition/nutritional_plan_model_test.dart @@ -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', () { diff --git a/test/weight/weight_provider_test.dart b/test/weight/weight_provider_test.dart index 72488713..08ce8c66 100644 --- a/test/weight/weight_provider_test.dart +++ b/test/weight/weight_provider_test.dart @@ -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); diff --git a/test/workout/workout_form_test.dart b/test/workout/workout_form_test.dart index 75af21b4..a3ddd7f4 100644 --- a/test/workout/workout_form_test.dart +++ b/test/workout/workout_form_test.dart @@ -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)); diff --git a/test/workout/workout_provider_test.dart b/test/workout/workout_provider_test.dart index f49ee03a..1bcb7d4f 100644 --- a/test/workout/workout_provider_test.dart +++ b/test/workout/workout_provider_test.dart @@ -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( diff --git a/test/workout/workout_set_form_test.dart b/test/workout/workout_set_form_test.dart index 3d298007..50479298 100644 --- a/test/workout/workout_set_form_test.dart +++ b/test/workout/workout_set_form_test.dart @@ -57,16 +57,17 @@ void main() { [workoutPlan], ), child: ChangeNotifierProvider( - create: (context) => mockExerciseProvider, - child: MaterialApp( - locale: Locale(locale), - localizationsDelegates: AppLocalizations.localizationsDelegates, - supportedLocales: AppLocalizations.supportedLocales, - navigatorKey: GlobalKey(), - home: Scaffold( - body: SetFormWidget(day), - ), - )), + create: (context) => mockExerciseProvider, + child: MaterialApp( + locale: Locale(locale), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + navigatorKey: GlobalKey(), + home: Scaffold( + body: SetFormWidget(day), + ), + ), + ), ); } diff --git a/test_data/gallery.dart b/test_data/gallery.dart index dd69a114..5d18d14d 100644 --- a/test_data/gallery.dart +++ b/test_data/gallery.dart @@ -47,6 +47,6 @@ List 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), - ) + ), ]; } diff --git a/test_data/screenshots_exercises.dart b/test_data/screenshots_exercises.dart index c9663f5d..743474bc 100644 --- a/test_data/screenshots_exercises.dart +++ b/test_data/screenshots_exercises.dart @@ -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(