stack_wallet/test/notifications/notification_card_test.dart

72 lines
2.1 KiB
Dart
Raw Normal View History

2022-10-24 15:16:08 +00:00
import 'package:flutter/material.dart';
2023-05-14 03:32:49 +00:00
import 'package:flutter_riverpod/flutter_riverpod.dart';
2022-10-24 15:16:08 +00:00
import 'package:flutter_svg/svg.dart';
import 'package:flutter_test/flutter_test.dart';
2023-05-14 03:32:49 +00:00
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
2023-05-12 20:02:04 +00:00
import 'package:stackwallet/models/isar/stack_theme.dart';
2022-10-24 15:16:08 +00:00
import 'package:stackwallet/models/notification_model.dart';
import 'package:stackwallet/notifications/notification_card.dart';
import 'package:stackwallet/themes/stack_colors.dart';
2023-05-14 03:32:49 +00:00
import 'package:stackwallet/themes/theme_service.dart';
2022-10-24 15:16:08 +00:00
import 'package:stackwallet/utilities/assets.dart';
2023-05-12 20:02:04 +00:00
import '../sample_data/theme_json.dart';
2023-05-14 03:32:49 +00:00
import 'notification_card_test.mocks.dart';
2022-10-24 15:16:08 +00:00
2023-05-14 03:32:49 +00:00
@GenerateMocks([
ThemeService,
])
2022-10-24 15:16:08 +00:00
void main() {
testWidgets("test notification card", (widgetTester) async {
final key = UniqueKey();
2023-05-14 03:32:49 +00:00
final mockThemeService = MockThemeService();
final theme = StackTheme.fromJson(
json: lightThemeJsonMap,
);
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => theme,
);
2022-10-24 15:16:08 +00:00
final notificationCard = NotificationCard(
key: key,
notification: NotificationModel(
id: 1,
title: "notification title",
description: "notification description",
2023-05-12 20:02:04 +00:00
iconAssetName: Assets.svg.plus,
2022-10-24 15:16:08 +00:00
date: DateTime.parse("1662544771"),
walletId: "wallet id",
read: true,
shouldWatchForUpdates: true,
coinName: "Bitcoin"),
);
await widgetTester.pumpWidget(
2023-05-14 03:32:49 +00:00
ProviderScope(
overrides: [
pThemeService.overrideWithValue(mockThemeService),
],
child: MaterialApp(
theme: ThemeData(
extensions: [
StackColors.fromStackColorTheme(
theme,
2023-05-08 17:59:00 +00:00
),
2023-05-14 03:32:49 +00:00
],
),
home: Material(
child: notificationCard,
),
2022-10-24 15:16:08 +00:00
),
),
);
expect(find.byWidget(notificationCard), findsOneWidget);
expect(find.text("notification title"), findsOneWidget);
expect(find.text("notification description"), findsOneWidget);
expect(find.byType(SvgPicture), findsOneWidget);
});
}