mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
WIP: Widget tests
This commit is contained in:
parent
1c2cd82292
commit
bb40d4b165
3 changed files with 109 additions and 196 deletions
|
@ -21,12 +21,10 @@ class MockedFunctions extends Mock {
|
|||
|
||||
@GenerateMocks([AddressBookService])
|
||||
void main() {
|
||||
group('Navigation tests', () {
|
||||
late AddressBookService service;
|
||||
setUp(() {
|
||||
service = MockAddressBookService();
|
||||
testWidgets('test returns Contact Address Entry', (widgetTester) async {
|
||||
final service = MockAddressBookService();
|
||||
|
||||
when(service.getContactById("some id"))
|
||||
when(service.getContactById("default"))
|
||||
.thenAnswer((realInvocation) => Contact(
|
||||
name: "John Doe",
|
||||
addresses: [
|
||||
|
@ -36,9 +34,7 @@ void main() {
|
|||
label: "Bills")
|
||||
],
|
||||
isFavorite: true));
|
||||
});
|
||||
|
||||
testWidgets('test returns Contact Address Entry', (widgetTester) async {
|
||||
await widgetTester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
|
@ -55,173 +51,16 @@ void main() {
|
|||
],
|
||||
),
|
||||
home: const AddressBookCard(
|
||||
contactId: "some id",
|
||||
contactId: "default",
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text("John Doe"), findsOneWidget);
|
||||
expect(find.text("BCH"), findsOneWidget);
|
||||
expect(find.text(Coin.bitcoincash.ticker), findsOneWidget);
|
||||
|
||||
await widgetTester.tap(find.byType(RawMaterialButton));
|
||||
});
|
||||
|
||||
// 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",
|
||||
// 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();
|
||||
// });
|
||||
});
|
||||
|
||||
// testWidgets('test returns Contact Address Entry', (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(
|
||||
// serv,
|
||||
// ),
|
||||
// ],
|
||||
// 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",
|
||||
// // 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: "03177ce0-4af4-11ed-9617-af8aa7a3796f",
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// //
|
||||
// // 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));
|
||||
// // // when(contact)
|
||||
// // await widgetTester.pump();
|
||||
// });
|
||||
}
|
||||
|
|
70
test/widget_tests/desktop/desktop_scaffold_test.dart
Normal file
70
test/widget_tests/desktop/desktop_scaffold_test.dart
Normal file
|
@ -0,0 +1,70 @@
|
|||
import 'package:flutter/material.dart';
|
||||
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/desktop/desktop_scaffold.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets("test DesktopScaffold", (widgetTester) async {
|
||||
final key = UniqueKey();
|
||||
await widgetTester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(
|
||||
extensions: [
|
||||
StackColors.fromStackColorTheme(LightColors()),
|
||||
],
|
||||
),
|
||||
home: Material(
|
||||
child: DesktopScaffold(
|
||||
key: key,
|
||||
body: const SizedBox(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets("Test MasterScaffold for non desktop", (widgetTester) async {
|
||||
final key = UniqueKey();
|
||||
|
||||
await widgetTester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(
|
||||
extensions: [
|
||||
StackColors.fromStackColorTheme(LightColors()),
|
||||
],
|
||||
),
|
||||
home: Material(
|
||||
child: MasterScaffold(
|
||||
key: key,
|
||||
body: const SizedBox(),
|
||||
appBar: AppBar(),
|
||||
isDesktop: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets("Test MasterScaffold for desktop", (widgetTester) async {
|
||||
final key = UniqueKey();
|
||||
|
||||
await widgetTester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(
|
||||
extensions: [
|
||||
StackColors.fromStackColorTheme(LightColors()),
|
||||
],
|
||||
),
|
||||
home: Material(
|
||||
child: MasterScaffold(
|
||||
key: key,
|
||||
body: const SizedBox(),
|
||||
appBar: AppBar(),
|
||||
isDesktop: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
4
test/widget_tests/shake/shake_test.dart
Normal file
4
test/widget_tests/shake/shake_test.dart
Normal file
|
@ -0,0 +1,4 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stackwallet/utilities/theme/light_colors.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
Loading…
Reference in a new issue