Closed riscait closed 1 year ago
This solves a problem that I have with unit testing and the code looks reasonable to me. I pulled in the fork and have it working in my app now. This is a fork of the current release (as of this post). Do we have a maintainer?
For reference, I had an error message when running unit tests after importing the flutter_app_badger
package. The message was Binding has not yet been initialized.
and contained the app badger in the stack trace. By mocking out the app badger using the fork I was able to pass all tests.
Here is the code I used to mock out the library inside the setup() method of my unit tests:
FlutterAppBadger.setMocks(
isAppBadgeSupported: () => Future.value(false),
updateBadgeCount: (count) => Future.value(null),
);
Since this is a mock you should change the values to whatever your code is expecting.
Thank you, @riscait
Thanks for your PR @riscait
When testing, there was no way to use mocks, so I implemented them.
There may be a better implementation, in which case I would appreciate your advice.