2022-10-17 10:15:32 +00:00
|
|
|
import 'package:emojis/emoji.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
2022-11-25 23:49:47 +00:00
|
|
|
import 'package:mockingjay/mockingjay.dart' as mockingjay;
|
2022-10-17 10:15:32 +00:00
|
|
|
import 'package:stackwallet/utilities/theme/light_colors.dart';
|
|
|
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
|
|
|
import 'package:stackwallet/widgets/emoji_select_sheet.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
testWidgets("Widget displays correctly", (tester) async {
|
|
|
|
const emojiSelectSheet = EmojiSelectSheet();
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
MaterialApp(
|
|
|
|
theme: ThemeData(
|
|
|
|
extensions: [
|
|
|
|
StackColors.fromStackColorTheme(LightColors()),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
home: const Material(
|
|
|
|
child: emojiSelectSheet,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(find.byWidget(emojiSelectSheet), findsOneWidget);
|
|
|
|
expect(find.text("Select emoji"), findsOneWidget);
|
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets("Emoji tapped test", (tester) async {
|
|
|
|
const emojiSelectSheet = EmojiSelectSheet();
|
|
|
|
|
|
|
|
final navigator = mockingjay.MockNavigator();
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
ProviderScope(
|
|
|
|
overrides: [],
|
|
|
|
child: MaterialApp(
|
|
|
|
theme: ThemeData(
|
|
|
|
extensions: [
|
|
|
|
StackColors.fromStackColorTheme(LightColors()),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
home: mockingjay.MockNavigatorProvider(
|
2022-11-25 23:49:47 +00:00
|
|
|
navigator: navigator,
|
|
|
|
child: Column(
|
|
|
|
children: const [
|
|
|
|
Expanded(child: emojiSelectSheet),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-10-17 10:15:32 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2022-11-25 23:49:47 +00:00
|
|
|
final gestureDetector = find.byType(GestureDetector).at(5);
|
2022-10-17 10:15:32 +00:00
|
|
|
expect(gestureDetector, findsOneWidget);
|
|
|
|
|
2022-11-25 23:49:47 +00:00
|
|
|
final emoji = Emoji.byChar("😅");
|
2022-10-17 10:15:32 +00:00
|
|
|
|
|
|
|
await tester.tap(gestureDetector);
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
mockingjay.verify(() => navigator.pop(emoji)).called(1);
|
|
|
|
});
|
|
|
|
}
|