LCOV - code coverage report
Current view: top level - test-doubles/auth/data - firebase_auth_example.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 10 0.0 %
Date: 2022-03-03 12:15:14 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:firebase_auth/firebase_auth.dart';
       2             : import 'package:mockito/mockito.dart';
       3             : 
       4             : import '../../firebase/mocks/firebase_test_doubles.mocks.dart';
       5             : import 'user_example.dart';
       6             : 
       7             : class FirebaseAuthExample {
       8             :   /// Emits a User with null members then a FirebaseUser with random
       9             :   /// values (this follows the pattern when a user is signed in and starts the app)
      10             : 
      11             :   /// We mock a UserCredntial and stub the MockFirebaseAuth so that calling
      12             :   /// signInWithCredential returns the currently signed-in [User],
      13             :   /// or `null` if there isn't any (i.e. the user is signed out).
      14           0 :   static FirebaseAuth get signedInMock {
      15           0 :     final mockUserCredential = MockUserCredential();
      16           0 :     final stubbedUser = UserExample.stubBasicMock();
      17           0 :     when(mockUserCredential.user).thenReturn(stubbedUser);
      18             : 
      19           0 :     final mockFirebaseAuth = MockFirebaseAuth();
      20           0 :     final anotherStubbedUser = UserExample.stubBasicMock();
      21           0 :     when(mockFirebaseAuth.authStateChanges())
      22           0 :         .thenAnswer((_) => Stream.fromIterable([null, anotherStubbedUser]));
      23           0 :     when(mockFirebaseAuth.signInWithCredential(any))
      24           0 :         .thenAnswer((_) => Future.value(mockUserCredential));
      25             : 
      26             :     return mockFirebaseAuth;
      27             :   }
      28             : }

Generated by: LCOV version 1.13