0% found this document useful (0 votes)
11 views

Gapi Utils Test - Dart

from dart plugins source archieve
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Gapi Utils Test - Dart

from dart plugins source archieve
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

// Copyright 2019 The Chromium Authors. All rights reserved.

// Use of this source code is governed by a BSD-style license that can be


// found in the LICENSE file.
@TestOn('browser')

import 'package:flutter_test/flutter_test.dart';

import 'package:google_sign_in_web/src/generated/gapiauth2.dart' as gapi;


import 'package:google_sign_in_web/src/utils.dart';
import 'package:mockito/mockito.dart';

class MockGoogleUser extends Mock implements gapi.GoogleUser {}

class MockBasicProfile extends Mock implements gapi.BasicProfile {}

void main() {
// The non-null use cases are covered by the auth2_test.dart file.

group('gapiUserToPluginUserData', () {
var mockUser;

setUp(() {
mockUser = MockGoogleUser();
});

test('null user -> null response', () {


expect(gapiUserToPluginUserData(null), isNull);
});

test('not signed-in user -> null response', () {


when(mockUser.isSignedIn()).thenReturn(false);
expect(gapiUserToPluginUserData(mockUser), isNull);
});

test('signed-in, but null profile user -> null response', () {


when(mockUser.isSignedIn()).thenReturn(true);
expect(gapiUserToPluginUserData(mockUser), isNull);
});

test('signed-in, null userId in profile user -> null response', () {


when(mockUser.isSignedIn()).thenReturn(true);
when(mockUser.getBasicProfile()).thenReturn(MockBasicProfile());
expect(gapiUserToPluginUserData(mockUser), isNull);
});
});
}

You might also like