Skip to content

Commit

Permalink
wip nfc cut global default initialToken
Browse files Browse the repository at this point in the history
  • Loading branch information
gnprice committed Oct 16, 2023
1 parent 3edce3e commit 835d5e3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/model/binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class TestZulipBinding extends ZulipBinding {
}

class FakeFirebaseMessaging extends Fake implements FirebaseMessaging {
String _initialToken = '0123456789abcdef';
String? _initialToken;

/// Set the token to a new value, as if it were newly generated.
///
Expand All @@ -208,9 +208,14 @@ class FakeFirebaseMessaging extends Fake implements FirebaseMessaging {
Future<String?> getToken({String? vapidKey}) async {
assert(vapidKey == null);
if (_token == null) {
assert(_initialToken != null,
'Tests that call [NotificationService.start], or otherwise cause'
' a call to `ZulipBinding.instance.firebaseMessaging.getToken`,'
' must set `testBinding.firebaseMessagingInitialToken` first.');

// This causes [onTokenRefresh] to fire, just like the real [getToken]
// does when no token exists (e.g., on first run after install).
setToken(_initialToken);
setToken(_initialToken!);
}
return _token;
}
Expand Down

0 comments on commit 835d5e3

Please sign in to comment.