forked from segmentio/analytics_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mocks.dart
40 lines (36 loc) · 1.26 KB
/
mocks.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
32
33
34
35
36
37
38
39
40
import 'dart:async';
import 'package:segment_analytics/analytics_platform_interface.dart';
import 'package:segment_analytics/logger.dart';
import 'package:segment_analytics/native_context.dart';
import 'package:segment_analytics/utils/http_client.dart';
import 'package:segment_analytics/utils/store/store.dart';
import 'package:http/http.dart';
import 'package:mockito/annotations.dart';
@GenerateNiceMocks([
MockSpec<LogTarget>(),
MockSpec<Request>(),
MockSpec<StreamSubscription>(),
MockSpec<HTTPClient>(),
MockSpec<Store>()
])
import 'mocks.mocks.dart';
class MockPlatform extends AnalyticsPlatform {
@override
Future<NativeContext> getContext({bool collectDeviceId = false}) {
return Future.value(NativeContext(
app: NativeContextApp(),
device: NativeContextDevice(),
library: NativeContextLibrary(),
network: NativeContextNetwork(),
os: NativeContextOS(),
screen: NativeContextScreen()));
}
}
class Mocks {
static MockLogTarget logTarget() => MockLogTarget();
static MockRequest request() => MockRequest();
static MockStreamSubscription<T> streamSubscription<T>() =>
MockStreamSubscription<T>();
static MockHTTPClient httpClient() => MockHTTPClient();
static MockStore store() => MockStore();
}