|
1 | | -// import 'package:flutter/material.dart'; |
2 | | -// import 'package:flutter_svg/svg.dart'; |
3 | | -// import 'package:flutter_test/flutter_test.dart'; |
4 | | -// import 'package:stackduo/models/notification_model.dart'; |
5 | | -// import 'package:stackduo/notifications/notification_card.dart'; |
6 | | -// import 'package:stackduo/utilities/assets.dart'; |
7 | | -// import 'package:stackduo/utilities/enums/coin_enum.dart'; |
8 | | -// import 'package:stackduo/utilities/theme/light_colors.dart'; |
9 | | -// import 'package:stackduo/utilities/theme/stack_colors.dart'; |
10 | | -// |
11 | | -// void main() { |
12 | | -// testWidgets("test notification card", (widgetTester) async { |
13 | | -// final key = UniqueKey(); |
14 | | -// final notificationCard = NotificationCard( |
15 | | -// key: key, |
16 | | -// notification: NotificationModel( |
17 | | -// id: 1, |
18 | | -// title: "notification title", |
19 | | -// description: "notification description", |
20 | | -// iconAssetName: Assets.svg.iconFor(coin: Coin.bitcoin), |
21 | | -// date: DateTime.parse("1662544771"), |
22 | | -// walletId: "wallet id", |
23 | | -// read: true, |
24 | | -// shouldWatchForUpdates: true, |
25 | | -// coinName: "Bitcoin"), |
26 | | -// ); |
27 | | -// |
28 | | -// await widgetTester.pumpWidget( |
29 | | -// MaterialApp( |
30 | | -// theme: ThemeData( |
31 | | -// extensions: [ |
32 | | -// StackColors.fromStackColorTheme(LightColors()), |
33 | | -// ], |
34 | | -// ), |
35 | | -// home: Material( |
36 | | -// child: notificationCard, |
37 | | -// ), |
38 | | -// ), |
39 | | -// ); |
40 | | -// |
41 | | -// expect(find.byWidget(notificationCard), findsOneWidget); |
42 | | -// expect(find.text("notification title"), findsOneWidget); |
43 | | -// expect(find.text("notification description"), findsOneWidget); |
44 | | -// expect(find.byType(SvgPicture), findsOneWidget); |
45 | | -// }); |
46 | | -// } |
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:flutter_riverpod/flutter_riverpod.dart'; |
| 3 | +import 'package:flutter_svg/svg.dart'; |
| 4 | +import 'package:flutter_test/flutter_test.dart'; |
| 5 | +import 'package:mockito/annotations.dart'; |
| 6 | +import 'package:mockito/mockito.dart'; |
| 7 | +import 'package:stackwallet/models/isar/stack_theme.dart'; |
| 8 | +import 'package:stackwallet/models/notification_model.dart'; |
| 9 | +import 'package:stackwallet/notifications/notification_card.dart'; |
| 10 | +import 'package:stackwallet/themes/stack_colors.dart'; |
| 11 | +import 'package:stackwallet/themes/theme_service.dart'; |
| 12 | +import 'package:stackwallet/utilities/assets.dart'; |
| 13 | + |
| 14 | +import '../sample_data/theme_json.dart'; |
| 15 | +import 'notification_card_test.mocks.dart'; |
| 16 | + |
| 17 | +@GenerateMocks([ |
| 18 | + ThemeService, |
| 19 | +]) |
| 20 | +void main() { |
| 21 | + testWidgets("test notification card", (widgetTester) async { |
| 22 | + final key = UniqueKey(); |
| 23 | + final mockThemeService = MockThemeService(); |
| 24 | + final theme = StackTheme.fromJson( |
| 25 | + json: lightThemeJsonMap, |
| 26 | + ); |
| 27 | + |
| 28 | + when(mockThemeService.getTheme(themeId: "light")).thenAnswer( |
| 29 | + (_) => theme, |
| 30 | + ); |
| 31 | + |
| 32 | + final notificationCard = NotificationCard( |
| 33 | + key: key, |
| 34 | + notification: NotificationModel( |
| 35 | + id: 1, |
| 36 | + title: "notification title", |
| 37 | + description: "notification description", |
| 38 | + iconAssetName: Assets.svg.plus, |
| 39 | + date: DateTime.parse("1662544771"), |
| 40 | + walletId: "wallet id", |
| 41 | + read: true, |
| 42 | + shouldWatchForUpdates: true, |
| 43 | + coinName: "Bitcoin"), |
| 44 | + ); |
| 45 | + |
| 46 | + await widgetTester.pumpWidget( |
| 47 | + ProviderScope( |
| 48 | + overrides: [ |
| 49 | + pThemeService.overrideWithValue(mockThemeService), |
| 50 | + ], |
| 51 | + child: MaterialApp( |
| 52 | + theme: ThemeData( |
| 53 | + extensions: [ |
| 54 | + StackColors.fromStackColorTheme( |
| 55 | + theme, |
| 56 | + ), |
| 57 | + ], |
| 58 | + ), |
| 59 | + home: Material( |
| 60 | + child: notificationCard, |
| 61 | + ), |
| 62 | + ), |
| 63 | + ), |
| 64 | + ); |
| 65 | + |
| 66 | + expect(find.byWidget(notificationCard), findsOneWidget); |
| 67 | + expect(find.text("notification title"), findsOneWidget); |
| 68 | + expect(find.text("notification description"), findsOneWidget); |
| 69 | + expect(find.byType(SvgPicture), findsOneWidget); |
| 70 | + }); |
| 71 | +} |
0 commit comments