Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jorre127 committed Oct 10, 2024
1 parent 66b976c commit c96e4fc
Show file tree
Hide file tree
Showing 10 changed files with 1,920 additions and 421 deletions.
24 changes: 15 additions & 9 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
global_options:
flutter_navigation_generator:flutter_navigator_builder:
runs_before:
- mockito|mockBuilder

targets:
$default:
builders:
flutter_navigation_generator:flutter_route_builder:
generate_for:
include:
- lib/screen/**.dart
flutter_navigation_generator:flutter_navigator_builder:
generate_for:
include:
- lib/navigator/main_navigator.dart
drift_dev:
generate_for:
include:
- lib/database/**.dart
- lib/model/database/**.dart
# Should be removed in the future
retrofit_generator|retrofit:
enabled: true
Expand All @@ -24,12 +38,4 @@ targets:
injectable_generator:injectable_config_builder:
generate_for:
include:
- lib/di/injectable.dart
flutter_navigation_generator:flutter_route_builder:
generate_for:
include:
- lib/screen/**.dart
flutter_navigation_generator:flutter_navigator_builder:
generate_for:
include:
- lib/navigator/main_navigator.dart
- lib/di/injectable.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_template/styles/theme_dimens.dart';
import 'package:flutter_template/styles/theme_durations.dart';
import 'package:flutter_template/util/extension/text_scaler_extension.dart';
import 'package:flutter_template/util/extension/text_scaler_extensions.dart';
import 'package:flutter_template/widget/animation/animated_color_filter.dart';
import 'package:flutter_template/widget/provider/data_provider_widget.dart';
import 'package:icapps_architecture/icapps_architecture.dart';
Expand Down
228 changes: 207 additions & 21 deletions test/util/test_util.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i5;
import 'dart:ui' as _i3;
import 'dart:ui' as _i4;

import 'package:drift/drift.dart' as _i11;
import 'package:flutter/material.dart' as _i4;
import 'package:flutter/material.dart' as _i1;
import 'package:flutter_template/model/snackbar/snackbar_data.dart' as _i12;
import 'package:flutter_template/navigator/main_navigator.dart' as _i10;
import 'package:flutter_template/util/locale/localization.dart' as _i7;
import 'package:flutter_template/util/snackbar/error_util.dart' as _i9;
import 'package:flutter_template/viewmodel/global/global_viewmodel.dart' as _i2;
import 'package:flutter_template/viewmodel/global/global_viewmodel.dart' as _i3;
import 'package:icapps_architecture/icapps_architecture.dart' as _i8;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/mockito.dart' as _i2;
import 'package:mockito/src/dummies.dart' as _i6;

// ignore_for_file: type=lint
Expand All @@ -30,25 +30,36 @@ import 'package:mockito/src/dummies.dart' as _i6;
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class

class _FakeGlobalKey_0<T extends _i1.State<_i1.StatefulWidget>>
extends _i2.SmartFake implements _i1.GlobalKey<T> {
_FakeGlobalKey_0(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
}

/// A class which mocks [GlobalViewModel].
///
/// See the documentation for Mockito's code generation for more information.
class MockGlobalViewModel extends _i1.Mock implements _i2.GlobalViewModel {
class MockGlobalViewModel extends _i2.Mock implements _i3.GlobalViewModel {
MockGlobalViewModel() {
_i1.throwOnMissingStub(this);
_i2.throwOnMissingStub(this);
}

@override
List<_i3.Locale> get supportedLocales => (super.noSuchMethod(
List<_i4.Locale> get supportedLocales => (super.noSuchMethod(
Invocation.getter(#supportedLocales),
returnValue: <_i3.Locale>[],
) as List<_i3.Locale>);
returnValue: <_i4.Locale>[],
) as List<_i4.Locale>);

@override
_i4.ThemeMode get themeMode => (super.noSuchMethod(
_i1.ThemeMode get themeMode => (super.noSuchMethod(
Invocation.getter(#themeMode),
returnValue: _i4.ThemeMode.system,
) as _i4.ThemeMode);
returnValue: _i1.ThemeMode.system,
) as _i1.ThemeMode);

@override
bool get showsTranslationKeys => (super.noSuchMethod(
Expand Down Expand Up @@ -79,7 +90,7 @@ class MockGlobalViewModel extends _i1.Mock implements _i2.GlobalViewModel {
) as _i5.Future<void>);

@override
_i5.Future<void> updateThemeMode(_i4.ThemeMode? themeMode) =>
_i5.Future<void> updateThemeMode(_i1.ThemeMode? themeMode) =>
(super.noSuchMethod(
Invocation.method(
#updateThemeMode,
Expand Down Expand Up @@ -223,7 +234,7 @@ class MockGlobalViewModel extends _i1.Mock implements _i2.GlobalViewModel {
);

@override
void addListener(_i3.VoidCallback? listener) => super.noSuchMethod(
void addListener(_i4.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
Expand All @@ -232,7 +243,7 @@ class MockGlobalViewModel extends _i1.Mock implements _i2.GlobalViewModel {
);

@override
void removeListener(_i3.VoidCallback? listener) => super.noSuchMethod(
void removeListener(_i4.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],
Expand Down Expand Up @@ -272,15 +283,15 @@ class MockGlobalViewModel extends _i1.Mock implements _i2.GlobalViewModel {
/// A class which mocks [ErrorUtil].
///
/// See the documentation for Mockito's code generation for more information.
class MockErrorUtil extends _i1.Mock implements _i9.ErrorUtil {
class MockErrorUtil extends _i2.Mock implements _i9.ErrorUtil {
MockErrorUtil() {
_i1.throwOnMissingStub(this);
_i2.throwOnMissingStub(this);
}

@override
String? showError({
required dynamic error,
required _i4.BuildContext? context,
required _i1.BuildContext? context,
}) =>
(super.noSuchMethod(Invocation.method(
#showError,
Expand All @@ -294,7 +305,7 @@ class MockErrorUtil extends _i1.Mock implements _i9.ErrorUtil {
@override
void showErrorWithLocaleKey({
required String? messageKey,
required _i4.BuildContext? context,
required _i1.BuildContext? context,
String? titleKey,
List<dynamic>? args,
}) =>
Expand All @@ -316,11 +327,20 @@ class MockErrorUtil extends _i1.Mock implements _i9.ErrorUtil {
/// A class which mocks [MainNavigator].
///
/// See the documentation for Mockito's code generation for more information.
class MockMainNavigator extends _i1.Mock implements _i10.MainNavigator {
class MockMainNavigator extends _i2.Mock implements _i10.MainNavigator {
MockMainNavigator() {
_i1.throwOnMissingStub(this);
_i2.throwOnMissingStub(this);
}

@override
_i1.GlobalKey<_i1.NavigatorState> get navigatorKey => (super.noSuchMethod(
Invocation.getter(#navigatorKey),
returnValue: _FakeGlobalKey_0<_i1.NavigatorState>(
this,
Invocation.getter(#navigatorKey),
),
) as _i1.GlobalKey<_i1.NavigatorState>);

@override
_i5.Future<void> goToDatabase(_i11.GeneratedDatabase? db) =>
(super.noSuchMethod(
Expand Down Expand Up @@ -379,4 +399,170 @@ class MockMainNavigator extends _i1.Mock implements _i10.MainNavigator {
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);

@override
_i1.Route<dynamic>? onGenerateRoute(_i1.RouteSettings? settings) =>
(super.noSuchMethod(Invocation.method(
#onGenerateRoute,
[settings],
)) as _i1.Route<dynamic>?);

@override
void goToHomeScreen({_i1.Key? key}) => super.noSuchMethod(
Invocation.method(
#goToHomeScreen,
[],
{#key: key},
),
returnValueForMissingStub: null,
);

@override
void goToSplashScreen({_i1.Key? key}) => super.noSuchMethod(
Invocation.method(
#goToSplashScreen,
[],
{#key: key},
),
returnValueForMissingStub: null,
);

@override
_i5.Future<void> goToLicenseScreen({_i1.Key? key}) => (super.noSuchMethod(
Invocation.method(
#goToLicenseScreen,
[],
{#key: key},
),
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);

@override
_i5.Future<void> goToTodoAddScreen({_i1.Key? key}) => (super.noSuchMethod(
Invocation.method(
#goToTodoAddScreen,
[],
{#key: key},
),
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);

@override
_i5.Future<void> goToAnalyticsPermissionScreen({_i1.Key? key}) =>
(super.noSuchMethod(
Invocation.method(
#goToAnalyticsPermissionScreen,
[],
{#key: key},
),
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);

@override
void goToLoginScreen({_i1.Key? key}) => super.noSuchMethod(
Invocation.method(
#goToLoginScreen,
[],
{#key: key},
),
returnValueForMissingStub: null,
);

@override
_i5.Future<void> goToThemeModeSelectorScreen({_i1.Key? key}) =>
(super.noSuchMethod(
Invocation.method(
#goToThemeModeSelectorScreen,
[],
{#key: key},
),
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);

@override
_i5.Future<void> goToDebugPlatformSelectorScreen({_i1.Key? key}) =>
(super.noSuchMethod(
Invocation.method(
#goToDebugPlatformSelectorScreen,
[],
{#key: key},
),
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);

@override
_i5.Future<void> goToDebugScreen({_i1.Key? key}) => (super.noSuchMethod(
Invocation.method(
#goToDebugScreen,
[],
{#key: key},
),
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);

@override
void goBack() => super.noSuchMethod(
Invocation.method(
#goBack,
[],
),
returnValueForMissingStub: null,
);

@override
void goBackWithResult<T>({T? result}) => super.noSuchMethod(
Invocation.method(
#goBackWithResult,
[],
{#result: result},
),
returnValueForMissingStub: null,
);

@override
void popUntil(bool Function(_i1.Route<dynamic>)? predicate) =>
super.noSuchMethod(
Invocation.method(
#popUntil,
[predicate],
),
returnValueForMissingStub: null,
);

@override
void goBackTo(String? routeName) => super.noSuchMethod(
Invocation.method(
#goBackTo,
[routeName],
),
returnValueForMissingStub: null,
);

@override
_i5.Future<T?> showCustomDialog<T>({_i1.Widget? widget}) =>
(super.noSuchMethod(
Invocation.method(
#showCustomDialog,
[],
{#widget: widget},
),
returnValue: _i5.Future<T?>.value(),
) as _i5.Future<T?>);

@override
_i5.Future<T?> showBottomSheet<T>({_i1.Widget? widget}) =>
(super.noSuchMethod(
Invocation.method(
#showBottomSheet,
[],
{#widget: widget},
),
returnValue: _i5.Future<T?>.value(),
) as _i5.Future<T?>);
}
Loading

0 comments on commit c96e4fc

Please sign in to comment.