HomeX-It / open-mail-app-flutter

This library provides the ability to query the device for installed email apps and open those apps.
MIT License
36 stars 91 forks source link

Platform.isAndroid and Platform.isIOS while flutter test #29

Closed PeterMee closed 3 years ago

PeterMee commented 3 years ago

You are using Platform.isAndroid and Platform.isIOS in openMailApp (). It is a static property and cannot be simulated in the test. Can you use other platform checks so we can mimic the platform check in openMailApp () while a unit test like FakePlatform?

MisterJimson commented 3 years ago

Seems reasonable, do you have an example of a package that does this we can copy/learn from?

PeterMee commented 3 years ago

Hey, we switched for our projcet from final isAndroid = Platform.isAndroid; in import 'dart:io'; to final isAndroid = const LocalPlatform().isAndroid; in import 'package:platform/platform.dart';. That allows us to create a FakePlatform for the test. For more infos you can watch LocalPlatform on flutter.dev. It would be very nice and useful. Thanks.

MisterJimson commented 3 years ago

Can you take a look at https://github.com/HomeXLabs/open-mail-app-flutter/pull/30 and see if it fits your need? Added a sample test.

PeterMee commented 3 years ago

Perfekt! Exactly what we need. Thank you :)

MisterJimson commented 3 years ago

Closed in 0.3.0 :)