-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
227 additions
and
2 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
test/app/shared/widget/m_webview/cubit/m_webview_cubit_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:altme/app/app.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('MWebViewCubit', () { | ||
late MWebViewCubit cubit; | ||
|
||
setUp(() { | ||
cubit = MWebViewCubit(); | ||
}); | ||
|
||
tearDown(() { | ||
cubit.close(); | ||
}); | ||
|
||
test('initial state is true', () { | ||
expect(cubit.state, true); | ||
}); | ||
|
||
test('emits new state when setLoading is called', () { | ||
expect(cubit.state, true); | ||
cubit.setLoading(isLoading: false); | ||
expect(cubit.state, false); | ||
cubit.setLoading(isLoading: true); | ||
expect(cubit.state, true); | ||
}); | ||
}); | ||
} |
77 changes: 77 additions & 0 deletions
77
test/onboarding/activate_biometircs/cubit/active_biometrics_cubit_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import 'package:altme/app/app.dart'; | ||
import 'package:altme/dashboard/dashboard.dart'; | ||
import 'package:altme/onboarding/onboarding.dart'; | ||
|
||
import 'package:bloc_test/bloc_test.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
|
||
class MockProfileCubit extends MockCubit<ProfileState> | ||
implements ProfileCubit {} | ||
|
||
void main() { | ||
group('ActiveBiometricsCubit', () { | ||
late ActiveBiometricsCubit activeBiometricsCubit; | ||
late MockProfileCubit mockProfileCubit; | ||
|
||
setUp(() { | ||
mockProfileCubit = MockProfileCubit(); | ||
|
||
activeBiometricsCubit = | ||
ActiveBiometricsCubit(profileCubit: mockProfileCubit); | ||
}); | ||
|
||
test('initial state is false', () { | ||
expect(activeBiometricsCubit.state, false); | ||
}); | ||
|
||
blocTest<ActiveBiometricsCubit, bool>( | ||
'load emits true if walletProtectionType is FA2 or biometrics', | ||
build: () { | ||
when(() => mockProfileCubit.state).thenReturn( | ||
ProfileState( | ||
model: ProfileModel( | ||
polygonIdNetwork: PolygonIdNetwork.PolygonMainnet, | ||
walletType: WalletType.personal, | ||
walletProtectionType: WalletProtectionType.biometrics, | ||
isDeveloperMode: false, | ||
profileType: ProfileType.custom, | ||
profileSetting: ProfileSetting.initial(), | ||
), | ||
), | ||
); | ||
return activeBiometricsCubit; | ||
}, | ||
act: (cubit) => cubit.load(), | ||
expect: () => [true], | ||
); | ||
|
||
blocTest<ActiveBiometricsCubit, bool>( | ||
'load emits false if walletProtectionType is not FA2 or biometrics', | ||
build: () { | ||
when(() => mockProfileCubit.state).thenReturn( | ||
ProfileState( | ||
model: ProfileModel( | ||
polygonIdNetwork: PolygonIdNetwork.PolygonMainnet, | ||
walletType: WalletType.personal, | ||
walletProtectionType: WalletProtectionType.pinCode, | ||
isDeveloperMode: false, | ||
profileType: ProfileType.custom, | ||
profileSetting: ProfileSetting.initial(), | ||
), | ||
), | ||
); | ||
return activeBiometricsCubit; | ||
}, | ||
act: (cubit) => cubit.load(), | ||
expect: () => [false], | ||
); | ||
|
||
blocTest<ActiveBiometricsCubit, bool>( | ||
'updateSwitch emits the provided value', | ||
build: () => activeBiometricsCubit, | ||
act: (cubit) => cubit.updateSwitch(value: true), | ||
expect: () => [true], | ||
); | ||
}); | ||
} |
26 changes: 26 additions & 0 deletions
26
test/onboarding/activate_biometircs/widgets/biometrics_switch_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:altme/app/app.dart'; | ||
import 'package:altme/onboarding/onboarding.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../../../helpers/helpers.dart'; | ||
|
||
void main() { | ||
group('BiometricsSwitch', () { | ||
testWidgets('renders value correctly', (tester) async { | ||
await tester.pumpApp(const BiometricsSwitch(value: true)); | ||
|
||
expect( | ||
find.byWidgetPredicate( | ||
(widget) => | ||
widget is Image && | ||
widget.image is AssetImage && | ||
(widget.image as AssetImage).assetName == | ||
IconStrings.fingerprint2, | ||
), | ||
findsOneWidget, | ||
); | ||
expect(find.byType(CupertinoSwitch), findsOneWidget); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:altme/app/app.dart'; | ||
import 'package:altme/onboarding/cubit/onboarding_cubit.dart'; | ||
import 'package:bloc_test/bloc_test.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('OnboardingCubit', () { | ||
test('initial state is correct', () { | ||
expect(OnboardingCubit().state, const OnboardingState()); | ||
}); | ||
|
||
blocTest<OnboardingCubit, OnboardingState>( | ||
'emits [loading] when emitOnboardingProcessing is called', | ||
build: OnboardingCubit.new, | ||
act: (cubit) => cubit.emitOnboardingProcessing(), | ||
expect: () => [const OnboardingState(status: AppStatus.loading)], | ||
); | ||
|
||
blocTest<OnboardingCubit, OnboardingState>( | ||
'emits [success] when emitOnboardingDone is called', | ||
build: OnboardingCubit.new, | ||
act: (cubit) => cubit.emitOnboardingDone(), | ||
expect: () => [const OnboardingState(status: AppStatus.success)], | ||
); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters