update test

This commit is contained in:
julian 2023-05-13 21:32:49 -06:00
parent 539dec13f5
commit 3e51624631
2 changed files with 154 additions and 12 deletions

View file

@ -1,17 +1,35 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:stackwallet/models/isar/stack_theme.dart';
import 'package:stackwallet/models/notification_model.dart';
import 'package:stackwallet/notifications/notification_card.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/themes/theme_service.dart';
import 'package:stackwallet/utilities/assets.dart';
import '../sample_data/theme_json.dart';
import 'notification_card_test.mocks.dart';
@GenerateMocks([
ThemeService,
])
void main() {
testWidgets("test notification card", (widgetTester) async {
final key = UniqueKey();
final mockThemeService = MockThemeService();
final theme = StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
);
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => theme,
);
final notificationCard = NotificationCard(
key: key,
notification: NotificationModel(
@ -27,19 +45,21 @@ void main() {
);
await widgetTester.pumpWidget(
MaterialApp(
theme: ThemeData(
extensions: [
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
ProviderScope(
overrides: [
pThemeService.overrideWithValue(mockThemeService),
],
child: MaterialApp(
theme: ThemeData(
extensions: [
StackColors.fromStackColorTheme(
theme,
),
),
],
),
home: Material(
child: notificationCard,
],
),
home: Material(
child: notificationCard,
),
),
),
);

View file

@ -0,0 +1,122 @@
// Mocks generated by Mockito 5.3.2 from annotations
// in stackwallet/test/notifications/notification_card_test.dart.
// Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i5;
import 'dart:typed_data' as _i6;
import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/db/isar/main_db.dart' as _i2;
import 'package:stackwallet/models/isar/stack_theme.dart' as _i4;
import 'package:stackwallet/themes/theme_service.dart' as _i3;
// ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values
// ignore_for_file: avoid_setters_without_getters
// ignore_for_file: comment_references
// ignore_for_file: implementation_imports
// ignore_for_file: invalid_use_of_visible_for_testing_member
// ignore_for_file: prefer_const_constructors
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
class _FakeMainDB_0 extends _i1.SmartFake implements _i2.MainDB {
_FakeMainDB_0(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
}
/// A class which mocks [ThemeService].
///
/// See the documentation for Mockito's code generation for more information.
class MockThemeService extends _i1.Mock implements _i3.ThemeService {
MockThemeService() {
_i1.throwOnMissingStub(this);
}
@override
_i2.MainDB get db => (super.noSuchMethod(
Invocation.getter(#db),
returnValue: _FakeMainDB_0(
this,
Invocation.getter(#db),
),
) as _i2.MainDB);
@override
List<_i4.StackTheme> get installedThemes => (super.noSuchMethod(
Invocation.getter(#installedThemes),
returnValue: <_i4.StackTheme>[],
) as List<_i4.StackTheme>);
@override
void init(_i2.MainDB? db) => super.noSuchMethod(
Invocation.method(
#init,
[db],
),
returnValueForMissingStub: null,
);
@override
_i5.Future<void> install({required _i6.Uint8List? themeArchiveData}) =>
(super.noSuchMethod(
Invocation.method(
#install,
[],
{#themeArchiveData: themeArchiveData},
),
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);
@override
_i5.Future<void> remove({required String? themeId}) => (super.noSuchMethod(
Invocation.method(
#remove,
[],
{#themeId: themeId},
),
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);
@override
_i5.Future<bool> verifyInstalled({required String? themeId}) =>
(super.noSuchMethod(
Invocation.method(
#verifyInstalled,
[],
{#themeId: themeId},
),
returnValue: _i5.Future<bool>.value(false),
) as _i5.Future<bool>);
@override
_i5.Future<List<_i3.StackThemeMetaData>> fetchThemes() => (super.noSuchMethod(
Invocation.method(
#fetchThemes,
[],
),
returnValue: _i5.Future<List<_i3.StackThemeMetaData>>.value(
<_i3.StackThemeMetaData>[]),
) as _i5.Future<List<_i3.StackThemeMetaData>>);
@override
_i5.Future<_i6.Uint8List> fetchTheme(
{required _i3.StackThemeMetaData? themeMetaData}) =>
(super.noSuchMethod(
Invocation.method(
#fetchTheme,
[],
{#themeMetaData: themeMetaData},
),
returnValue: _i5.Future<_i6.Uint8List>.value(_i6.Uint8List(0)),
) as _i5.Future<_i6.Uint8List>);
@override
_i4.StackTheme? getTheme({required String? themeId}) =>
(super.noSuchMethod(Invocation.method(
#getTheme,
[],
{#themeId: themeId},
)) as _i4.StackTheme?);
}