-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_dependencies.dart
31 lines (25 loc) · 1.06 KB
/
test_dependencies.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import 'package:flutter/widgets.dart';
import 'package:weather_app/app_dependencies/app_dependencies.dart';
import 'package:weather_app/prelude/time_source.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:provider/provider.dart';
import 'networking/test_async_compute.dart';
import 'networking/test_http_client_provider.dart';
import 'prelude/test_time_source.dart';
final class TestDependencies {
final TestHttpClientProvider http = TestHttpClientProvider();
final TimeSource timeSource = TestTimeSource();
AppDependencies buildAppDependencies() => AppDependencies(
httpClientProvider: http,
asyncCompute: TestAsyncCompute(),
timeSource: timeSource,
);
}
extension WidgetTesterWithTestDependencies on WidgetTester {
Future<TestDependencies> pumpWithTestDependencies(Widget widget) async {
final testDependencies = TestDependencies();
final appDependencies = testDependencies.buildAppDependencies();
await pumpWidget(Provider(create: (_) => appDependencies, child: widget));
return testDependencies;
}
}