Progress bar widget test and clean node_options test

This commit is contained in:
Likho 2022-10-18 17:49:09 +02:00
parent d22746be52
commit ffc1b19495
2 changed files with 92 additions and 0 deletions

View file

@ -151,4 +151,63 @@ void main() {
arguments: const Tuple3(Coin.bitcoin, "node id", "coinNodes")))
.called(1);
});
testWidgets("Connect tap", (tester) async {
final mockWallets = MockWallets();
final mockPrefs = MockPrefs();
final mockNodeService = MockNodeService();
when(mockNodeService.getNodeById(id: "node id")).thenAnswer(
(realInvocation) => NodeModel(
host: "127.0.0.1",
port: 2000,
name: "Stack Default",
id: "node id",
useSSL: true,
enabled: true,
coinName: "Bitcoin",
isFailover: false,
isDown: false));
when(mockNodeService.getPrimaryNodeFor(coin: Coin.bitcoin)).thenAnswer(
(realInvocation) => NodeModel(
host: "127.0.0.1",
port: 2000,
name: "Some other node name",
id: "some node id",
useSSL: true,
enabled: true,
coinName: "Bitcoin",
isFailover: false,
isDown: false));
await tester.pumpWidget(
ProviderScope(
overrides: [
walletsChangeNotifierProvider.overrideWithValue(mockWallets),
prefsChangeNotifierProvider.overrideWithValue(mockPrefs),
nodeServiceChangeNotifierProvider.overrideWithValue(mockNodeService)
],
child: MaterialApp(
theme: ThemeData(
extensions: [
StackColors.fromStackColorTheme(
LightColors(),
),
],
),
home: const NodeOptionsSheet(
nodeId: "node id", coin: Coin.bitcoin, popBackToRoute: ""),
),
),
);
await tester.pumpAndSettle();
expect(find.text("Node options"), findsOneWidget);
// expect(find.text("Stack Default"), findsOneWidget);
expect(find.text("Disconnected"), findsOneWidget);
await tester.tap(find.text("Connect"));
await tester.pumpAndSettle();
});
}

View file

@ -0,0 +1,33 @@
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/progress_bar.dart';
// import 'package:stackwallet/widgets/animated_text.dart';
void main() {
testWidgets("Widget build", (widgetTester) async {
await widgetTester.pumpWidget(
MaterialApp(
theme: ThemeData(
extensions: [
StackColors.fromStackColorTheme(LightColors()),
],
),
home: Material(
child: ProgressBar(
width: 20,
height: 10,
fillColor:
StackColors.fromStackColorTheme(LightColors()).accentColorRed,
backgroundColor: StackColors.fromStackColorTheme(LightColors())
.accentColorYellow,
percent: 30),
),
),
);
// expect(find.text("Calculating"), findsOneWidget);
expect(find.byType(ProgressBar), findsOneWidget);
});
}