mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
EmojiSelect widget test
This commit is contained in:
parent
be45315487
commit
145da3cc3c
2 changed files with 133 additions and 73 deletions
|
@ -26,48 +26,6 @@ void main() {
|
|||
setUp(() {
|
||||
service = MockAddressBookService();
|
||||
|
||||
// when(service.getContactById("some id"))
|
||||
// .thenAnswer((realInvocation) => Contact(
|
||||
// name: "John Doe",
|
||||
// addresses: [
|
||||
// const ContactAddressEntry(
|
||||
// coin: Coin.bitcoincash,
|
||||
// address: "some bch address",
|
||||
// label: "Bills")
|
||||
// ],
|
||||
// isFavorite: true));
|
||||
});
|
||||
|
||||
// testWidgets('test returns Contact Address Entry', (widgetTester) async {
|
||||
// await widgetTester.pumpWidget(
|
||||
// ProviderScope(
|
||||
// overrides: [
|
||||
// addressBookServiceProvider.overrideWithValue(
|
||||
// service,
|
||||
// ),
|
||||
// ],
|
||||
// child: MaterialApp(
|
||||
// theme: ThemeData(
|
||||
// extensions: [
|
||||
// StackColors.fromStackColorTheme(
|
||||
// LightColors(),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// home: const AddressBookCard(
|
||||
// contactId: "some id",
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
//
|
||||
// expect(find.text("John Doe"), findsOneWidget);
|
||||
// expect(find.text(Coin.bitcoincash.ticker), findsOneWidget);
|
||||
// });
|
||||
|
||||
testWidgets("Test button press opens dialog", (widgetTester) async {
|
||||
// final service = MockAddressBookService();
|
||||
|
||||
when(service.getContactById("some id"))
|
||||
.thenAnswer((realInvocation) => Contact(
|
||||
name: "John Doe",
|
||||
|
@ -78,7 +36,9 @@ void main() {
|
|||
label: "Bills")
|
||||
],
|
||||
isFavorite: true));
|
||||
});
|
||||
|
||||
testWidgets('test returns Contact Address Entry', (widgetTester) async {
|
||||
await widgetTester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
|
@ -100,7 +60,60 @@ void main() {
|
|||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text("John Doe"), findsOneWidget);
|
||||
expect(find.text(Coin.bitcoincash.ticker), findsOneWidget);
|
||||
});
|
||||
|
||||
// testWidgets("Test button press opens dialog", (widgetTester) async {
|
||||
// // final service = MockAddressBookService();
|
||||
//
|
||||
// when(service.getContactById("some id"))
|
||||
// .thenAnswer((realInvocation) => Contact(
|
||||
// name: "John Doe",
|
||||
// addresses: [
|
||||
// const ContactAddressEntry(
|
||||
// coin: Coin.bitcoincash,
|
||||
// address: "some bch address",
|
||||
// label: "Bills")
|
||||
// ],
|
||||
// isFavorite: true));
|
||||
//
|
||||
// await widgetTester.pumpWidget(
|
||||
// ProviderScope(
|
||||
// overrides: [
|
||||
// addressBookServiceProvider.overrideWithValue(
|
||||
// service,
|
||||
// ),
|
||||
// ],
|
||||
// child: MaterialApp(
|
||||
// theme: ThemeData(
|
||||
// extensions: [
|
||||
// StackColors.fromStackColorTheme(
|
||||
// LightColors(),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// home: const AddressBookCard(
|
||||
// contactId: "some id",
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// //
|
||||
// // when(service.getContactById("03177ce0-4af4-11ed-9617-af8aa7a3796f"))
|
||||
// // .thenAnswer((realInvocation) => Contact(
|
||||
// // name: "John Doe",
|
||||
// // addresses: [
|
||||
// // const ContactAddressEntry(
|
||||
// // coin: Coin.bitcoincash,
|
||||
// // address: "some bch address",
|
||||
// // label: "Bills")
|
||||
// // ],
|
||||
// // isFavorite: true));
|
||||
// await widgetTester.tap(find.byType(RawMaterialButton));
|
||||
// // verify(MockedFunctions().showDialog()).called(1);
|
||||
// await widgetTester.pump();
|
||||
// when(service.getContactById("03177ce0-4af4-11ed-9617-af8aa7a3796f"))
|
||||
// .thenAnswer((realInvocation) => Contact(
|
||||
// name: "John Doe",
|
||||
|
@ -111,28 +124,15 @@ void main() {
|
|||
// label: "Bills")
|
||||
// ],
|
||||
// isFavorite: true));
|
||||
await widgetTester.tap(find.byType(RawMaterialButton));
|
||||
// verify(MockedFunctions().showDialog()).called(1);
|
||||
await widgetTester.pump();
|
||||
when(service.getContactById("03177ce0-4af4-11ed-9617-af8aa7a3796f"))
|
||||
.thenAnswer((realInvocation) => Contact(
|
||||
name: "John Doe",
|
||||
addresses: [
|
||||
const ContactAddressEntry(
|
||||
coin: Coin.bitcoincash,
|
||||
address: "some bch address",
|
||||
label: "Bills")
|
||||
],
|
||||
isFavorite: true));
|
||||
|
||||
expect(
|
||||
find.byWidget(const ContactPopUp(
|
||||
contactId: "03177ce0-4af4-11ed-9617-af8aa7a3796f")),
|
||||
findsOneWidget);
|
||||
// await widgetTester.pump();
|
||||
// // when(contact)
|
||||
// await widgetTester.pump();
|
||||
});
|
||||
//
|
||||
// expect(
|
||||
// find.byWidget(const ContactPopUp(
|
||||
// contactId: "03177ce0-4af4-11ed-9617-af8aa7a3796f")),
|
||||
// findsOneWidget);
|
||||
// // await widgetTester.pump();
|
||||
// // // when(contact)
|
||||
// // await widgetTester.pump();
|
||||
// });
|
||||
});
|
||||
|
||||
// testWidgets('test returns Contact Address Entry', (widgetTester) async {
|
||||
|
|
60
test/widget_tests/emoji_select_sheet_test.dart
Normal file
60
test/widget_tests/emoji_select_sheet_test.dart
Normal file
|
@ -0,0 +1,60 @@
|
|||
import 'package:emojis/emoji.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mockingjay/mockingjay.dart' as mockingjay;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
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(
|
||||
navigator: navigator, child: emojiSelectSheet),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final gestureDetector = find.byType(GestureDetector).first;
|
||||
expect(gestureDetector, findsOneWidget);
|
||||
|
||||
final emoji = Emoji.all()[0];
|
||||
|
||||
await tester.tap(gestureDetector);
|
||||
await tester.pumpAndSettle();
|
||||
mockingjay.verify(() => navigator.pop(emoji)).called(1);
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue