-
-
Notifications
You must be signed in to change notification settings - Fork 223
/
sentry_app_test.dart
108 lines (95 loc) · 3.48 KB
/
sentry_app_test.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import 'package:collection/collection.dart';
import 'package:sentry/sentry.dart';
import 'package:test/test.dart';
void main() {
final testStartTime = DateTime.fromMicrosecondsSinceEpoch(0);
final sentryApp = SentryApp(
name: 'fixture-name',
version: 'fixture-version',
identifier: 'fixture-identifier',
build: 'fixture-build',
buildType: 'fixture-buildType',
startTime: testStartTime,
deviceAppHash: 'fixture-deviceAppHash',
inForeground: true,
viewNames: ['fixture-viewName', 'fixture-viewName2'],
textScale: 'fixture-textScale',
);
final sentryAppJson = <String, dynamic>{
'app_name': 'fixture-name',
'app_version': 'fixture-version',
'app_identifier': 'fixture-identifier',
'app_build': 'fixture-build',
'build_type': 'fixture-buildType',
'app_start_time': testStartTime.toIso8601String(),
'device_app_hash': 'fixture-deviceAppHash',
'in_foreground': true,
'view_names': ['fixture-viewName', 'fixture-viewName2'],
'text_scale': 'fixture-textScale',
};
group('json', () {
test('toJson', () {
final json = sentryApp.toJson();
expect(json['app_name'], 'fixture-name');
expect(json['app_version'], 'fixture-version');
expect(json['app_identifier'], 'fixture-identifier');
expect(json['app_build'], 'fixture-build');
expect(json['build_type'], 'fixture-buildType');
expect(json['app_start_time'], testStartTime.toIso8601String());
expect(json['device_app_hash'], 'fixture-deviceAppHash');
expect(json['in_foreground'], true);
expect(json['view_names'], ['fixture-viewName', 'fixture-viewName2']);
expect(json['text_scale'], 'fixture-textScale');
});
test('fromJson', () {
final sentryApp = SentryApp.fromJson(sentryAppJson);
final json = sentryApp.toJson();
expect(json['app_name'], 'fixture-name');
expect(json['app_version'], 'fixture-version');
expect(json['app_identifier'], 'fixture-identifier');
expect(json['app_build'], 'fixture-build');
expect(json['build_type'], 'fixture-buildType');
expect(json['app_start_time'], testStartTime.toIso8601String());
expect(json['device_app_hash'], 'fixture-deviceAppHash');
expect(json['in_foreground'], true);
expect(json['view_names'], ['fixture-viewName', 'fixture-viewName2']);
expect(json['text_scale'], 'fixture-textScale');
});
});
group('copyWith', () {
test('copyWith keeps unchanged', () {
final data = sentryApp;
final copy = data.copyWith();
expect(
MapEquality().equals(data.toJson(), copy.toJson()),
true,
);
});
test('copyWith takes new values', () {
final data = sentryApp;
final startTime = DateTime.now();
final copy = data.copyWith(
name: 'name1',
version: 'version1',
identifier: 'identifier1',
build: 'build1',
buildType: 'buildType1',
startTime: startTime,
deviceAppHash: 'hash1',
inForeground: true,
viewNames: ['screen1'],
textScale: 'textScale1',
);
expect('name1', copy.name);
expect('version1', copy.version);
expect('identifier1', copy.identifier);
expect('build1', copy.build);
expect('buildType1', copy.buildType);
expect(startTime, copy.startTime);
expect('hash1', copy.deviceAppHash);
expect(true, copy.inForeground);
expect(['screen1'], copy.viewNames);
expect('textScale1', copy.textScale);
});
});
}