-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpermission_service_test.dart
36 lines (26 loc) · 1.18 KB
/
permission_service_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
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:smart_link/services/permission_service.dart';
import 'permission_service_test.mocks.dart';
@GenerateNiceMocks([MockSpec<BluetoothPermissionService>()])
void main() {
group('BluetoothPermissionService tests', () {
late IPermissionService permissionService;
setUp(() {
permissionService = MockBluetoothPermissionService();
});
test('requestPermissions should return true if all permissions are granted', () async {
when(permissionService.requestPermissions()).thenAnswer((_) async => true);
final bool result = await permissionService.requestPermissions();
verify(permissionService.requestPermissions()).called(1);
expect(result, true);
});
test('requestPermissions should return false if any permission is not granted', () async {
when(permissionService.requestPermissions()).thenAnswer((_) async => false);
final bool result = await permissionService.requestPermissions();
verify(permissionService.requestPermissions()).called(1);
expect(result, false);
});
});
}