Skip to content

Commit

Permalink
Fix error in widget test caused by wrong mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbendebiene committed Aug 5, 2024
1 parent 9900922 commit 97e17eb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,22 @@ void main() {

// mock geolocator
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
const MethodChannel('flutter.baseflow.com/geolocator'), (methodCall) async {
const MethodChannel('flutter.baseflow.com/geolocator'), (methodCall) {
if (methodCall.method == 'isLocationServiceEnabled') {
return false;
return Future.value(false);
}
if (methodCall.method == 'checkPermission') {
return 1;
if (methodCall.method == 'requestPermission') {
// results in deniedForever
return Future.value(1);
}
return null;
}
);
// mock sensors
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
const MethodChannel('flutter_sensors'), (methodCall) async {
const MethodChannel('flutter_sensors'), (methodCall) {
if (methodCall.method == 'is_sensor_available') {
return false;
return Future.value(false);
}
return null;
}
Expand Down

0 comments on commit 97e17eb

Please sign in to comment.