mirror of
https://github.com/wger-project/flutter.git
synced 2026-12-01 02:02:35 +01:00
dcm fix --only-rules=avoid-redundant-async
This commit is contained in:
@@ -34,7 +34,7 @@ class MeasurementCategoriesScreen extends StatelessWidget {
|
||||
appBar: AppBar(title: Text(AppLocalizations.of(context).measurements)),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.add, color: Colors.white),
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
|
||||
@@ -122,7 +122,7 @@ class MeasurementEntriesScreen extends StatelessWidget {
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.add, color: Colors.white),
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
|
||||
@@ -209,7 +209,7 @@ class _DashboardWeightWidgetState extends State<DashboardWeightWidget> {
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
@@ -526,7 +526,7 @@ class NothingFound extends StatelessWidget {
|
||||
IconButton(
|
||||
iconSize: 30,
|
||||
icon: const Icon(Icons.add_box, color: wgerPrimaryButtonColor),
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
FormScreen.routeName,
|
||||
|
||||
@@ -41,7 +41,7 @@ void main() {
|
||||
await ServiceLocator().configure();
|
||||
});
|
||||
|
||||
setUp(() async {
|
||||
setUp(() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
driftRuntimeOptions.dontWarnAboutMultipleDatabases = true;
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ void main() {
|
||||
fixture('exercises/exercisebaseinfo_response.json'),
|
||||
);
|
||||
|
||||
setUpAll(() async {
|
||||
setUpAll(() {
|
||||
// Needs to be configured here, setUp runs on every test, setUpAll only once
|
||||
//await ServiceLocator().configure();
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ void main() {
|
||||
);
|
||||
|
||||
group('Model tests', () {
|
||||
test('test getExercise', () async {
|
||||
test('test getExercise', () {
|
||||
// arrange and act
|
||||
final base = getTestExercises()[1];
|
||||
|
||||
|
||||
@@ -240,13 +240,13 @@ void main() {
|
||||
|
||||
test(
|
||||
'should re-add the "removed" MeasurementCategory and relay the exception on WgerHttpException',
|
||||
() async {
|
||||
() {
|
||||
// arrange
|
||||
when(mockWgerBaseProvider.deleteRequest(any, any)).thenThrow(WgerHttpException('{}'));
|
||||
|
||||
// act & assert
|
||||
expect(() async => measurementProvider.deleteCategory(tCategoryId),
|
||||
throwsA(isA<WgerHttpException>()));
|
||||
expect(
|
||||
() => measurementProvider.deleteCategory(tCategoryId), throwsA(isA<WgerHttpException>()));
|
||||
expect(measurementProvider.categories, tMeasurementCategories);
|
||||
});
|
||||
});
|
||||
@@ -279,9 +279,7 @@ void main() {
|
||||
|
||||
test("should throw a NoSuchEntryException if category doesn't exist", () {
|
||||
// act & assert
|
||||
expect(
|
||||
() async =>
|
||||
measurementProvider.editCategory(83, tCategoryEditedName, tCategoryEditedUnit),
|
||||
expect(() => measurementProvider.editCategory(83, tCategoryEditedName, tCategoryEditedUnit),
|
||||
throwsA(isA<NoSuchEntryException>()));
|
||||
});
|
||||
|
||||
@@ -439,7 +437,7 @@ void main() {
|
||||
|
||||
test("should throw a NoSuchEntryException if the category isn't found", () {
|
||||
// act & assert
|
||||
expect(() async => measurementProvider.deleteEntry(tEntryId, 83),
|
||||
expect(() => measurementProvider.deleteEntry(tEntryId, 83),
|
||||
throwsA(isA<NoSuchEntryException>()));
|
||||
});
|
||||
|
||||
@@ -461,7 +459,7 @@ void main() {
|
||||
|
||||
test(
|
||||
'should re-add the "removed" MeasurementEntry and throw a WgerHttpException if the api call fails',
|
||||
() async {
|
||||
() {
|
||||
// arrange
|
||||
final List<MeasurementCategory> tMeasurementCategories = [
|
||||
MeasurementCategory(id: 1, name: 'Strength', unit: 'kN', entries: [
|
||||
@@ -485,7 +483,7 @@ void main() {
|
||||
when(mockWgerBaseProvider.deleteRequest(any, any)).thenThrow(WgerHttpException('{}'));
|
||||
|
||||
// act & assert
|
||||
expect(() async => measurementProvider.deleteEntry(tEntryId, tCategoryId),
|
||||
expect(() => measurementProvider.deleteEntry(tEntryId, tCategoryId),
|
||||
throwsA(isA<WgerHttpException>()));
|
||||
expect(measurementProvider.categories, tMeasurementCategories);
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ import 'base_provider_test.mocks.dart';
|
||||
@GenerateMocks([http.Client])
|
||||
void main() {
|
||||
group('test base provider', () {
|
||||
test('Test the makeUrl helper', () async {
|
||||
test('Test the makeUrl helper', () {
|
||||
final WgerBaseProvider provider = WgerBaseProvider(testAuthProvider);
|
||||
|
||||
expect(
|
||||
@@ -63,7 +63,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('Test the makeUrl helper with sub url', () async {
|
||||
test('Test the makeUrl helper with sub url', () {
|
||||
// Trailing slash is removed when saving the server URL
|
||||
testAuthProvider.serverUrl = 'https://example.com/wger-url';
|
||||
final WgerBaseProvider provider = WgerBaseProvider(testAuthProvider);
|
||||
|
||||
@@ -21,7 +21,7 @@ import 'package:wger/models/body_weight/weight_entry.dart';
|
||||
|
||||
void main() {
|
||||
group('fetchPost', () {
|
||||
test('Test that the weight entries are correctly converted to json', () async {
|
||||
test('Test that the weight entries are correctly converted to json', () {
|
||||
WeightEntry weightEntry = WeightEntry(id: 1, weight: 80, date: DateTime(2020, 12, 31));
|
||||
expect(weightEntry.toJson(), {'id': 1, 'weight': '80', 'date': '2020-12-31'});
|
||||
|
||||
@@ -29,7 +29,7 @@ void main() {
|
||||
expect(weightEntry.toJson(), {'id': 2, 'weight': '70.2', 'date': '2020-12-01'});
|
||||
});
|
||||
|
||||
test('Test that the weight entries are correctly converted from json', () async {
|
||||
test('Test that the weight entries are correctly converted from json', () {
|
||||
final WeightEntry weightEntryObj =
|
||||
WeightEntry(id: 1, weight: 80, date: DateTime(2020, 12, 31));
|
||||
final WeightEntry weightEntry = WeightEntry.fromJson({
|
||||
|
||||
@@ -22,7 +22,7 @@ import 'package:wger/helpers/gym_mode.dart';
|
||||
|
||||
void main() {
|
||||
group('Test the plate calculator', () {
|
||||
test('Regular weights', () async {
|
||||
test('Regular weights', () {
|
||||
expect(plateCalculator(40, BAR_WEIGHT, AVAILABLE_PLATES), [10]);
|
||||
expect(plateCalculator(100, BAR_WEIGHT, AVAILABLE_PLATES), [15, 15, 10]);
|
||||
expect(plateCalculator(102.5, BAR_WEIGHT, AVAILABLE_PLATES), [15, 15, 10, 1.25]);
|
||||
@@ -31,7 +31,7 @@ void main() {
|
||||
expect(plateCalculator(85, BAR_WEIGHT, AVAILABLE_PLATES), [15, 15, 2.5]);
|
||||
});
|
||||
|
||||
test('Exceptions', () async {
|
||||
test('Exceptions', () {
|
||||
expect(
|
||||
plateCalculator(10, BAR_WEIGHT, AVAILABLE_PLATES),
|
||||
[],
|
||||
@@ -47,7 +47,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('Test the plate calculator group', () {
|
||||
test('Test groups', () async {
|
||||
test('Test groups', () {
|
||||
expect(groupPlates([15, 15, 15, 10, 10, 5]), {15: 3, 10: 2, 5: 1});
|
||||
expect(groupPlates([15, 10, 5, 1.25]), {15: 1, 10: 1, 5: 1, 1.25: 1});
|
||||
expect(groupPlates([10, 10, 10, 10, 10, 10, 10]), {10: 7});
|
||||
|
||||
@@ -22,7 +22,7 @@ import '../../test_data/workouts.dart';
|
||||
|
||||
void main() {
|
||||
group('Test the getSmartTextRepr method for a set', () {
|
||||
test('Repetitions and weigh units', () async {
|
||||
test('Repetitions and weigh units', () {
|
||||
final workout = getWorkout();
|
||||
final set = workout.days.first.sets.first;
|
||||
final exercise1 = set.exerciseBasesObj[0];
|
||||
|
||||
@@ -23,7 +23,7 @@ import 'package:wger/models/workouts/weight_unit.dart';
|
||||
|
||||
void main() {
|
||||
group('Test the singleSettingRepText method', () {
|
||||
test('Default rep and weight units, no RiR', () async {
|
||||
test('Default rep and weight units, no RiR', () {
|
||||
const repUnit = RepetitionUnit(id: 1, name: 'mol');
|
||||
const weightUnit = WeightUnit(id: 1, name: 'mg');
|
||||
|
||||
@@ -36,7 +36,7 @@ void main() {
|
||||
expect(setting.singleSettingRepText, '2 × 30 mg');
|
||||
});
|
||||
|
||||
test('Default rep and weight units', () async {
|
||||
test('Default rep and weight units', () {
|
||||
const repUnit = RepetitionUnit(id: 1, name: 'mol');
|
||||
const weightUnit = WeightUnit(id: 1, name: 'mg');
|
||||
|
||||
@@ -49,7 +49,7 @@ void main() {
|
||||
expect(setting.singleSettingRepText, '2 × 30 mg \n (1.5 RiR)');
|
||||
});
|
||||
|
||||
test('No weight, default rep and weight units', () async {
|
||||
test('No weight, default rep and weight units', () {
|
||||
const repUnit = RepetitionUnit(id: 1, name: 'mol');
|
||||
const weightUnit = WeightUnit(id: 1, name: 'mg');
|
||||
|
||||
@@ -62,7 +62,7 @@ void main() {
|
||||
expect(setting.singleSettingRepText, '2 mol \n (1.5 RiR)');
|
||||
});
|
||||
|
||||
test('Custom rep and weight units, no RiR', () async {
|
||||
test('Custom rep and weight units, no RiR', () {
|
||||
const repUnit = RepetitionUnit(id: 2, name: 'mol');
|
||||
const weightUnit = WeightUnit(id: 2, name: 'mg');
|
||||
|
||||
@@ -75,7 +75,7 @@ void main() {
|
||||
expect(setting.singleSettingRepText, '2 mol × 30 mg');
|
||||
});
|
||||
|
||||
test('Custom rep and weight units, RiR', () async {
|
||||
test('Custom rep and weight units, RiR', () {
|
||||
const repUnit = RepetitionUnit(id: 2, name: 'mol');
|
||||
const weightUnit = WeightUnit(id: 2, name: 'mg');
|
||||
|
||||
|
||||
@@ -49,31 +49,31 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('Test equal values (besides Id, workoutPlan and date)', () async {
|
||||
test('Test equal values (besides Id, workoutPlan and date)', () {
|
||||
expect(log1, log2);
|
||||
});
|
||||
|
||||
test('Test different rir values', () async {
|
||||
test('Test different rir values', () {
|
||||
log1.rir = null;
|
||||
expect(log1, isNot(log2));
|
||||
});
|
||||
|
||||
test('Test different weight values', () async {
|
||||
test('Test different weight values', () {
|
||||
log1.weight = 100;
|
||||
expect(log1, isNot(log2));
|
||||
});
|
||||
|
||||
test('Test different weight units', () async {
|
||||
test('Test different weight units', () {
|
||||
log1.weightUnitId = 2;
|
||||
expect(log1, isNot(log2));
|
||||
});
|
||||
|
||||
test('Test different reps', () async {
|
||||
test('Test different reps', () {
|
||||
log1.reps = 99;
|
||||
expect(log1, isNot(log2));
|
||||
});
|
||||
|
||||
test('Test different rep units', () async {
|
||||
test('Test different rep units', () {
|
||||
log1.repetitionUnitId = 44;
|
||||
expect(log1, isNot(log2));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user