-
-
Notifications
You must be signed in to change notification settings - Fork 941
Expand file tree
/
Copy pathpermissions_test.dart
More file actions
88 lines (73 loc) · 2.35 KB
/
permissions_test.dart
File metadata and controls
88 lines (73 loc) · 2.35 KB
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
import 'package:flutter_test/flutter_test.dart';
import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart';
void main() {
test('Permission has the right amount of possible Permission values', () {
const values = Permission.values;
expect(values.length, 41);
});
test('check if byValue returns corresponding Permission value', () {
const values = Permission.values;
for (var i = 0; i < values.length; i++) {
expect(values[i], Permission.byValue(i));
}
});
test('check if toString method returns the corresponding name', () {
const PermissionWithService permissionWithService =
PermissionWithService.private(0);
var permissionName = permissionWithService.toString();
expect(permissionName, 'Permission.calendar');
});
test('check if toString works on all Permission values', () {
const values = Permission.values;
for (var i = 0; i < values.length; i++) {
expect(values[i].toString(), isNotNull);
}
});
test(
// ignore: lines_longer_than_80_chars
'equality operator should return true for two instances with the same values',
() {
// Arrange
final firstPermission = Permission.byValue(1);
final secondPermission = Permission.byValue(1);
// Act & Assert
expect(
firstPermission == secondPermission,
true,
);
});
test(
// ignore: lines_longer_than_80_chars
'equality operator should return false for two instances with different values',
() {
// Arrange
final firstPermission = Permission.byValue(1);
final secondPermission = Permission.byValue(2);
// Act & Assert
expect(
firstPermission == secondPermission,
false,
);
});
test('hashCode should be the same for two instances with the same values',
() {
// Arrange
final firstPermission = Permission.byValue(1);
final secondPermission = Permission.byValue(1);
// Act & Assert
expect(
firstPermission.hashCode,
secondPermission.hashCode,
);
});
test('hashCode should not match for two instances with different values', () {
// Arrange
final firstPermission = Permission.byValue(1);
final secondPermission = Permission.byValue(2);
// Act & Assert
expect(
firstPermission.hashCode == secondPermission.hashCode,
false,
);
});
}