Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-sneha-s committed Mar 11, 2024
1 parent 6f7da6f commit ee80fa8
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 143 deletions.
1 change: 0 additions & 1 deletion lib/data/di/service_locator.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/data/services/account_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AccountService {
fromFirestore: Account.fromFireStore,
toFirestore: (Account user, _) => user.toJson());

Future<Account> getUser(firebase_auth.User authData, {String? name}) async {
Future<Account> getUser(firebase_auth.User authData) async {
final userDataDoc = await _accountsDb.doc(authData.uid).get();
final Account user;
final Account? userData = userDataDoc.data();
Expand All @@ -29,7 +29,7 @@ class AccountService {
user = Account(
uid: authData.uid,
email: authData.email!,
name: name ?? authData.displayName);
name: authData.displayName);
await _accountsDb.doc(authData.uid).set(user);
}
await _setUserSession(authData.uid);
Expand Down
13 changes: 1 addition & 12 deletions lib/data/services/auth_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@ import 'package:google_sign_in/google_sign_in.dart';
import 'package:injectable/injectable.dart';
import 'package:oauth2/oauth2.dart';
import 'package:projectunity/data/services/account_service.dart';
import '../model/account/account.dart';
import '../state_manager/auth/desktop/desktop_auth_manager.dart';

@LazySingleton()
class AuthService {
final DesktopAuthManager _desktopAuthManager;
final FirebaseFirestore fireStore;
final AccountService _accountService;

final firebase_auth.FirebaseAuth firebaseAuth;

AuthService(this._desktopAuthManager, this.fireStore, this.firebaseAuth,
this._accountService);
AuthService(this._desktopAuthManager, this.fireStore, this.firebaseAuth);

Future<firebase_auth.User?> signInWithGoogle() async {
final GoogleSignIn googleSignIn = GoogleSignIn();
Expand Down Expand Up @@ -109,14 +106,6 @@ class AuthService {
return credential.user;
}

Future<Account?> setUser(firebase_auth.User? authUser, {String? name}) async {
if (authUser != null) {
final Account user = await _accountService.getUser(authUser, name: name);
return user;
}
return null;
}

Future<bool> signOut() async {
try {
await firebaseAuth.signOut();
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/sign_in/bloc/sign_in_view_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SignInBloc extends Bloc<SignInEvent, SignInState> {
} else {
emit(state.copyWith(appleSignInLoading: false));
}
} on Exception catch (e) {
} on Exception {
emit(state.copyWith(
appleSignInLoading: false, error: somethingWentWrongError));
}
Expand Down
1 change: 0 additions & 1 deletion lib/ui/sign_in/bloc/sign_in_view_event.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

abstract class SignInEvent {}

class GoogleSignInEvent extends SignInEvent {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,16 @@ class MockAccountService extends _i1.Mock implements _i8.AccountService {
) as _i3.DeviceInfoProvider);

@override
_i9.Future<_i4.Account> getUser(
_i10.User? authData, {
String? name,
}) =>
(super.noSuchMethod(
_i9.Future<_i4.Account> getUser(_i10.User? authData) => (super.noSuchMethod(
Invocation.method(
#getUser,
[authData],
{#name: name},
),
returnValue: _i9.Future<_i4.Account>.value(_FakeAccount_2(
this,
Invocation.method(
#getUser,
[authData],
{#name: name},
),
)),
) as _i9.Future<_i4.Account>);
Expand Down
72 changes: 11 additions & 61 deletions test/unit_test/authentication/login/login_bloc_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import 'dart:ui' as _i13;
import 'package:cloud_firestore/cloud_firestore.dart' as _i2;
import 'package:firebase_auth/firebase_auth.dart' as _i3;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i9;
import 'package:mockito/src/dummies.dart' as _i11;
import 'package:projectunity/data/model/account/account.dart' as _i5;
import 'package:projectunity/data/model/employee/employee.dart' as _i6;
import 'package:projectunity/data/model/space/space.dart' as _i12;
import 'package:projectunity/data/provider/device_info.dart' as _i4;
import 'package:projectunity/data/provider/user_state.dart' as _i11;
import 'package:projectunity/data/services/account_service.dart' as _i10;
import 'package:projectunity/data/provider/user_state.dart' as _i10;
import 'package:projectunity/data/services/account_service.dart' as _i9;
import 'package:projectunity/data/services/auth_service.dart' as _i7;

// ignore_for_file: type=lint
Expand Down Expand Up @@ -200,50 +200,6 @@ class MockAuthService extends _i1.Mock implements _i7.AuthService {
returnValue: _i8.Future<_i3.User?>.value(),
) as _i8.Future<_i3.User?>);

@override
_i8.Future<_i5.Account?> setUser(
_i3.User? authUser, {
String? name,
}) =>
(super.noSuchMethod(
Invocation.method(
#setUser,
[authUser],
{#name: name},
),
returnValue: _i8.Future<_i5.Account?>.value(),
) as _i8.Future<_i5.Account?>);

@override
String generateNounce([int? length = 32]) => (super.noSuchMethod(
Invocation.method(
#generateNounce,
[length],
),
returnValue: _i9.dummyValue<String>(
this,
Invocation.method(
#generateNounce,
[length],
),
),
) as String);

@override
String sha256ofString(String? input) => (super.noSuchMethod(
Invocation.method(
#sha256ofString,
[input],
),
returnValue: _i9.dummyValue<String>(
this,
Invocation.method(
#sha256ofString,
[input],
),
),
) as String);

@override
_i8.Future<bool> signOut() => (super.noSuchMethod(
Invocation.method(
Expand All @@ -257,7 +213,7 @@ class MockAuthService extends _i1.Mock implements _i7.AuthService {
/// A class which mocks [AccountService].
///
/// See the documentation for Mockito's code generation for more information.
class MockAccountService extends _i1.Mock implements _i10.AccountService {
class MockAccountService extends _i1.Mock implements _i9.AccountService {
MockAccountService() {
_i1.throwOnMissingStub(this);
}
Expand All @@ -281,22 +237,16 @@ class MockAccountService extends _i1.Mock implements _i10.AccountService {
) as _i4.DeviceInfoProvider);

@override
_i8.Future<_i5.Account> getUser(
_i3.User? authData, {
String? name,
}) =>
(super.noSuchMethod(
_i8.Future<_i5.Account> getUser(_i3.User? authData) => (super.noSuchMethod(
Invocation.method(
#getUser,
[authData],
{#name: name},
),
returnValue: _i8.Future<_i5.Account>.value(_FakeAccount_3(
this,
Invocation.method(
#getUser,
[authData],
{#name: name},
),
)),
) as _i8.Future<_i5.Account>);
Expand Down Expand Up @@ -370,21 +320,21 @@ class MockAccountService extends _i1.Mock implements _i10.AccountService {
/// A class which mocks [UserStateNotifier].
///
/// See the documentation for Mockito's code generation for more information.
class MockUserStateNotifier extends _i1.Mock implements _i11.UserStateNotifier {
class MockUserStateNotifier extends _i1.Mock implements _i10.UserStateNotifier {
MockUserStateNotifier() {
_i1.throwOnMissingStub(this);
}

@override
_i11.UserState get state => (super.noSuchMethod(
_i10.UserState get state => (super.noSuchMethod(
Invocation.getter(#state),
returnValue: _i11.UserState.authenticated,
) as _i11.UserState);
returnValue: _i10.UserState.authenticated,
) as _i10.UserState);

@override
String get employeeId => (super.noSuchMethod(
Invocation.getter(#employeeId),
returnValue: _i9.dummyValue<String>(
returnValue: _i11.dummyValue<String>(
this,
Invocation.getter(#employeeId),
),
Expand Down Expand Up @@ -589,7 +539,7 @@ class MockUser extends _i1.Mock implements _i3.User {
@override
String get uid => (super.noSuchMethod(
Invocation.getter(#uid),
returnValue: _i9.dummyValue<String>(
returnValue: _i11.dummyValue<String>(
this,
Invocation.getter(#uid),
),
Expand Down
8 changes: 1 addition & 7 deletions test/unit_test/shared/drawer/drawer_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -502,22 +502,16 @@ class MockAccountService extends _i1.Mock implements _i13.AccountService {
) as _i4.DeviceInfoProvider);

@override
_i8.Future<_i5.Account> getUser(
_i14.User? authData, {
String? name,
}) =>
(super.noSuchMethod(
_i8.Future<_i5.Account> getUser(_i14.User? authData) => (super.noSuchMethod(
Invocation.method(
#getUser,
[authData],
{#name: name},
),
returnValue: _i8.Future<_i5.Account>.value(_FakeAccount_3(
this,
Invocation.method(
#getUser,
[authData],
{#name: name},
),
)),
) as _i8.Future<_i5.Account>);
Expand Down
52 changes: 1 addition & 51 deletions test/unit_test/space/join_space/join_space_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -489,22 +489,16 @@ class MockAccountService extends _i1.Mock implements _i15.AccountService {
) as _i4.DeviceInfoProvider);

@override
_i8.Future<_i5.Account> getUser(
_i6.User? authData, {
String? name,
}) =>
(super.noSuchMethod(
_i8.Future<_i5.Account> getUser(_i6.User? authData) => (super.noSuchMethod(
Invocation.method(
#getUser,
[authData],
{#name: name},
),
returnValue: _i8.Future<_i5.Account>.value(_FakeAccount_3(
this,
Invocation.method(
#getUser,
[authData],
{#name: name},
),
)),
) as _i8.Future<_i5.Account>);
Expand Down Expand Up @@ -750,50 +744,6 @@ class MockAuthService extends _i1.Mock implements _i17.AuthService {
returnValue: _i8.Future<_i6.User?>.value(),
) as _i8.Future<_i6.User?>);

@override
_i8.Future<_i5.Account?> setUser(
_i6.User? authUser, {
String? name,
}) =>
(super.noSuchMethod(
Invocation.method(
#setUser,
[authUser],
{#name: name},
),
returnValue: _i8.Future<_i5.Account?>.value(),
) as _i8.Future<_i5.Account?>);

@override
String generateNounce([int? length = 32]) => (super.noSuchMethod(
Invocation.method(
#generateNounce,
[length],
),
returnValue: _i11.dummyValue<String>(
this,
Invocation.method(
#generateNounce,
[length],
),
),
) as String);

@override
String sha256ofString(String? input) => (super.noSuchMethod(
Invocation.method(
#sha256ofString,
[input],
),
returnValue: _i11.dummyValue<String>(
this,
Invocation.method(
#sha256ofString,
[input],
),
),
) as String);

@override
_i8.Future<bool> signOut() => (super.noSuchMethod(
Invocation.method(
Expand Down

0 comments on commit ee80fa8

Please sign in to comment.