Skip to content

Commit

Permalink
refactor: Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Oct 10, 2024
1 parent 515cec7 commit 56f393d
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:altme/activity_log/activity_log.dart';
import 'package:altme/app/app.dart';
import 'package:altme/chat_room/chat_room.dart';
import 'package:altme/dashboard/dashboard.dart';
Expand Down Expand Up @@ -68,6 +69,8 @@ class MockProfileCubit extends MockCubit<ProfileState> implements ProfileCubit {
final state = ProfileState(model: ProfileModel.empty());
}

class MockActivityLogManager extends Mock implements ActivityLogManager {}

void main() {
late DIDKitProvider didKitProvider;
late KeyGenerator keyGenerator;
Expand All @@ -78,6 +81,7 @@ void main() {
late MatrixNotificationCubit matrixNotificationCubit;
late ProfileCubit profileCubit;
late OnboardingCubit onboardingCubit;
late MockActivityLogManager activityLogManager;

setUpAll(() {
WidgetsFlutterBinding.ensureInitialized();
Expand All @@ -90,6 +94,7 @@ void main() {
matrixNotificationCubit = MockMatrixNotificationCubit();
profileCubit = MockProfileCubit();
onboardingCubit = OnboardingCubit();
activityLogManager = MockActivityLogManager();
});

group('OnBoarding GenPhrase Page', () {
Expand All @@ -107,6 +112,7 @@ void main() {
altmeChatSupportCubit: altmeChatSupportCubit,
matrixNotificationCubit: matrixNotificationCubit,
profileCubit: profileCubit,
activityLogManager: activityLogManager,
);
navigator = MockNavigator();
when(navigator.canPop).thenReturn(true);
Expand Down
7 changes: 7 additions & 0 deletions test/onboarding/helper_function/helper_function_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:altme/activity_log/activity_log.dart';
import 'package:altme/app/app.dart';
import 'package:altme/chat_room/chat_room.dart';
import 'package:altme/dashboard/dashboard.dart';
Expand Down Expand Up @@ -65,6 +66,8 @@ class MockLangCubit extends MockCubit<LangState> implements LangCubit {}

class MockOIDC4VC extends Mock implements OIDC4VC {}

class MockActivityLogManager extends Mock implements ActivityLogManager {}

void main() {
group('generateAccount', () {
late KeyGenerator keyGenerator;
Expand All @@ -76,6 +79,7 @@ void main() {
late MatrixNotificationCubit matrixNotificationCubit;
late ProfileCubit profileCubit;
late MockSecureStorageProvider secureStorageProvider;
late MockActivityLogManager activityLogManager;

setUp(() {
keyGenerator = KeyGenerator();
Expand All @@ -86,6 +90,7 @@ void main() {
altmeChatSupportCubit = MockAltmeChatSupportCubit();
matrixNotificationCubit = MockMatrixNotificationCubit();
secureStorageProvider = MockSecureStorageProvider();
activityLogManager = MockActivityLogManager();

when(() => secureStorageProvider.get(any())).thenAnswer((_) async => '');

Expand Down Expand Up @@ -116,6 +121,7 @@ void main() {
altmeChatSupportCubit: altmeChatSupportCubit,
matrixNotificationCubit: matrixNotificationCubit,
profileCubit: profileCubit,
activityLogManager: activityLogManager,
);

verify(
Expand Down Expand Up @@ -153,6 +159,7 @@ void main() {
altmeChatSupportCubit: altmeChatSupportCubit,
matrixNotificationCubit: matrixNotificationCubit,
profileCubit: profileCubit,
activityLogManager: activityLogManager,
);

expect(profileCubit.state.model.walletType, WalletType.enterprise);
Expand Down
15 changes: 15 additions & 0 deletions test/onboarding/protect_wallet/view/protect_wallet_page_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:convert';

import 'package:altme/activity_log/activity_log_manager.dart';
import 'package:altme/app/app.dart';
import 'package:altme/chat_room/chat_room.dart';
import 'package:altme/dashboard/dashboard.dart';
Expand Down Expand Up @@ -74,6 +75,8 @@ class MockLangCubit extends MockCubit<LangState> implements LangCubit {}

class MockOIDC4VC extends Mock implements OIDC4VC {}

class MockActivityLogManager extends Mock implements ActivityLogManager {}

void main() {
late DIDKitProvider didKitProvider;
late KeyGenerator keyGenerator;
Expand All @@ -85,6 +88,7 @@ void main() {
late OnboardingCubit onboardingCubit;
late MockSecureStorageProvider secureStorageProvider;
late MockOIDC4VC oidc4vc;
late MockActivityLogManager activityLogManager;

const mnemonicString =
'notice photo opera keen climb agent soft parrot best joke field devote';
Expand All @@ -109,6 +113,7 @@ void main() {
onboardingCubit = OnboardingCubit();
secureStorageProvider = MockSecureStorageProvider();
oidc4vc = MockOIDC4VC();
activityLogManager = MockActivityLogManager();

when(() => secureStorageProvider.get(any())).thenAnswer((_) async => '');

Expand Down Expand Up @@ -206,6 +211,7 @@ void main() {
secureStorageProvider: secureStorageProvider,
langCubit: MockLangCubit(),
),
activityLogManager: activityLogManager,
),
),
BlocProvider<HomeCubit>.value(value: homeCubit),
Expand Down Expand Up @@ -250,6 +256,7 @@ void main() {
altmeChatSupportCubit: altmeChatSupportCubit,
matrixNotificationCubit: matrixNotificationCubit,
profileCubit: profileCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down Expand Up @@ -294,6 +301,7 @@ void main() {
altmeChatSupportCubit: altmeChatSupportCubit,
matrixNotificationCubit: matrixNotificationCubit,
profileCubit: profileCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down Expand Up @@ -338,6 +346,7 @@ void main() {
altmeChatSupportCubit: altmeChatSupportCubit,
matrixNotificationCubit: matrixNotificationCubit,
profileCubit: profileCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down Expand Up @@ -394,6 +403,7 @@ void main() {
altmeChatSupportCubit: altmeChatSupportCubit,
matrixNotificationCubit: matrixNotificationCubit,
profileCubit: profileCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down Expand Up @@ -450,6 +460,7 @@ void main() {
altmeChatSupportCubit: altmeChatSupportCubit,
matrixNotificationCubit: matrixNotificationCubit,
profileCubit: profileCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down Expand Up @@ -506,6 +517,7 @@ void main() {
altmeChatSupportCubit: altmeChatSupportCubit,
matrixNotificationCubit: matrixNotificationCubit,
profileCubit: profileCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down Expand Up @@ -563,6 +575,7 @@ void main() {
altmeChatSupportCubit: altmeChatSupportCubit,
matrixNotificationCubit: matrixNotificationCubit,
profileCubit: profileCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down Expand Up @@ -629,6 +642,7 @@ void main() {
altmeChatSupportCubit: altmeChatSupportCubit,
matrixNotificationCubit: matrixNotificationCubit,
profileCubit: profileCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down Expand Up @@ -684,6 +698,7 @@ void main() {
altmeChatSupportCubit: altmeChatSupportCubit,
matrixNotificationCubit: matrixNotificationCubit,
profileCubit: profileCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:altme/activity_log/activity_log.dart';
import 'package:altme/app/app.dart';
import 'package:altme/chat_room/chat_room.dart';
import 'package:altme/dashboard/dashboard.dart';
Expand Down Expand Up @@ -78,6 +79,8 @@ class MockLangCubit extends MockCubit<LangState> implements LangCubit {}

class MockOIDC4VC extends Mock implements OIDC4VC {}

class MockActivityLogManager extends Mock implements ActivityLogManager {}

void main() {
late MockDIDKitProvider didKitProvider;
late KeyGenerator keyGenerator;
Expand All @@ -91,6 +94,7 @@ void main() {
late MockNavigator navigator;
late MockSecureStorageProvider secureStorageProvider;
late MockOIDC4VC oidc4vc;
late MockActivityLogManager activityLogManager;

const mnemonicString =
'notice photo opera keen climb agent soft parrot best joke field devote';
Expand All @@ -109,6 +113,7 @@ void main() {
navigator = MockNavigator();
secureStorageProvider = MockSecureStorageProvider();
oidc4vc = MockOIDC4VC();
activityLogManager = MockActivityLogManager();
});

group('Onboarding Verify Phrase Test', () {
Expand Down Expand Up @@ -183,6 +188,7 @@ void main() {
langCubit: MockLangCubit(),
),
flavorCubit: flavorCubit,
activityLogManager: activityLogManager,
),
),
BlocProvider<HomeCubit>.value(value: homeCubit),
Expand Down Expand Up @@ -230,6 +236,7 @@ void main() {
langCubit: MockLangCubit(),
),
flavorCubit: flavorCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down Expand Up @@ -277,6 +284,7 @@ void main() {
langCubit: MockLangCubit(),
),
flavorCubit: flavorCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down Expand Up @@ -356,6 +364,7 @@ void main() {
langCubit: MockLangCubit(),
),
flavorCubit: flavorCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down Expand Up @@ -429,6 +438,7 @@ void main() {
langCubit: MockLangCubit(),
),
flavorCubit: flavorCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down Expand Up @@ -483,6 +493,7 @@ void main() {
langCubit: MockLangCubit(),
),
flavorCubit: flavorCubit,
activityLogManager: activityLogManager,
);

await tester.pumpApp(
Expand Down
6 changes: 6 additions & 0 deletions test/scan/cubit/scan_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:altme/activity_log/activity_log.dart';
import 'package:altme/app/shared/shared.dart';
import 'package:altme/credentials/credentials.dart';
import 'package:altme/dashboard/profile/profile.dart';
Expand Down Expand Up @@ -26,6 +27,8 @@ class MockOIDC4VC extends Mock implements OIDC4VC {}

class MockJWTDecode extends Mock implements JWTDecode {}

class MockActivityLogManager extends Mock implements ActivityLogManager {}

void main() {
group('ScanCubit', () {
late MockDioClient mockDioClient;
Expand All @@ -37,6 +40,7 @@ void main() {
late MockOIDC4VC mockOIDC4VC;
late MockJWTDecode mockJWTDecode;
late ScanCubit scanCubit;
late ActivityLogManager activityLogManager;

setUp(() {
mockDioClient = MockDioClient();
Expand All @@ -47,6 +51,7 @@ void main() {
mockWalletCubit = MockWalletCubit();
mockOIDC4VC = MockOIDC4VC();
mockJWTDecode = MockJWTDecode();
activityLogManager = MockActivityLogManager();

scanCubit = ScanCubit(
client: mockDioClient,
Expand All @@ -57,6 +62,7 @@ void main() {
walletCubit: mockWalletCubit,
oidc4vc: mockOIDC4VC,
jwtDecode: mockJWTDecode,
activityLogManager: activityLogManager,
);
});

Expand Down

0 comments on commit 56f393d

Please sign in to comment.