stack_wallet/test/widget_tests/custom_loading_overlay_test.dart

54 lines
1.6 KiB
Dart
Raw Normal View History

import 'package:event_bus/event_bus.dart';
import 'package:flutter/material.dart';
2023-05-12 20:02:04 +00:00
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
2023-05-12 20:02:04 +00:00
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:stackwallet/models/isar/stack_theme.dart';
import 'package:stackwallet/themes/stack_colors.dart';
2023-05-12 20:02:04 +00:00
import 'package:stackwallet/themes/theme_service.dart';
import 'package:stackwallet/widgets/custom_loading_overlay.dart';
2023-05-12 20:02:04 +00:00
import '../sample_data/theme_json.dart';
import 'custom_loading_overlay_test.mocks.dart';
@GenerateMocks([
ThemeService,
])
void main() {
2023-05-12 20:02:04 +00:00
testWidgets("Test widget displays correct text", (widgetTester) async {
final eventBus = EventBus();
2023-05-12 20:02:04 +00:00
final mockThemeService = MockThemeService();
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
),
);
await widgetTester.pumpWidget(
2023-05-12 20:02:04 +00:00
ProviderScope(
overrides: [
pThemeService.overrideWithValue(mockThemeService),
],
child: MaterialApp(
theme: ThemeData(
extensions: [
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
),
2023-05-08 17:59:00 +00:00
),
2023-05-12 20:02:04 +00:00
],
),
home: Material(
child: CustomLoadingOverlay(
message: "Updating exchange rate", eventBus: eventBus),
),
),
),
);
expect(find.text("Updating exchange rate"), findsOneWidget);
});
}