google_sign_in_mocks 0.4.1 copy "google_sign_in_mocks: ^0.4.1" to clipboard
google_sign_in_mocks: ^0.4.1 copied to clipboard

Mocks for Google Sign In. Use this package with `firebase_auth_mocks` to write unit tests involving Firebase Authentication.

Mocks for google_sign_in. Use this package with firebase_auth_mocks to write unit tests involving Firebase Authentication.

pub package unit-tests Buy Me A Coffee

Usage #

A simple usage example:

import 'package:google_sign_in_mocks/google_sign_in_mocks.dart';
import 'package:test/test.dart';

void main() {
  late MockGoogleSignIn googleSignIn;
  setUp(() {
    googleSignIn = MockGoogleSignIn();
  });

  test('should return idToken when authenticating', () async {
    final signInAccount = await googleSignIn.signIn();
    final signInAuthentication = await signInAccount!.authentication;
    expect(signInAuthentication, isNotNull);
    expect(googleSignIn.currentUser, isNotNull);
    expect(signInAuthentication.idToken, isNotNull);
  });

  test('should return null when google login is cancelled by the user',
      () async {
    googleSignIn.setIsCancelled(true);
    final signInAccount = await googleSignIn.signIn();
    expect(signInAccount, isNull);
  });
  test('testing google login twice, once cancelled, once not cancelled at the same test.', () async {
   googleSignIn.setIsCancelled(true);
    final signInAccount = await googleSignIn.signIn();
    expect(signInAccount, isNull);
    googleSignIn.setIsCancelled(false);
    final signInAccountSecondAttempt = await googleSignIn.signIn();
    expect(signInAccountSecondAttempt, isNotNull);
  });
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

34
likes
150
points
8.15k
downloads

Documentation

API reference

Publisher

verified publisherwafrat.com

Weekly Downloads

Mocks for Google Sign In. Use this package with `firebase_auth_mocks` to write unit tests involving Firebase Authentication.

Homepage
Repository (GitHub)
View/report issues

License

BSD-2-Clause (license)

Dependencies

flutter, google_sign_in

More

Packages that depend on google_sign_in_mocks