changes
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tm_app/view_models/auth_view_model.dart';
|
||||
|
||||
import '../mocks/mock_auth_repository.dart';
|
||||
|
||||
void main() {
|
||||
group('AuthViewModel Initialization', () {
|
||||
late MockAuthRepository mockRepository;
|
||||
late AuthViewModel authViewModel;
|
||||
|
||||
setUp(() {
|
||||
mockRepository = MockAuthRepository();
|
||||
authViewModel = AuthViewModel(authRepository: mockRepository);
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
authViewModel.dispose();
|
||||
});
|
||||
|
||||
test('should initialize with default values', () {
|
||||
expect(authViewModel.isLoading, false);
|
||||
expect(authViewModel.isLoggedIn, false);
|
||||
expect(authViewModel.isLoadingForgot, false);
|
||||
expect(authViewModel.isLoadingOtp, false);
|
||||
expect(authViewModel.isResetPasswordLoading, false);
|
||||
expect(authViewModel.errorMessage, null);
|
||||
expect(authViewModel.errorMessageForget, null);
|
||||
expect(authViewModel.resetPasswordErrorMessage, null);
|
||||
expect(authViewModel.errorMessageOtp, null);
|
||||
expect(authViewModel.successMessageOtp, null);
|
||||
expect(authViewModel.verifyOtpSuccess, false);
|
||||
expect(authViewModel.loggedInUser, null);
|
||||
expect(authViewModel.forgotPasswordMessage, null);
|
||||
expect(authViewModel.resetToken, null);
|
||||
expect(authViewModel.resetPasswordSuccess, false);
|
||||
});
|
||||
|
||||
test('should initialize controllers with empty text', () {
|
||||
expect(authViewModel.usernameController.text, isEmpty);
|
||||
expect(authViewModel.passwordController.text, isEmpty);
|
||||
expect(authViewModel.emailController.text, isEmpty);
|
||||
expect(authViewModel.newPasswordController.text, isEmpty);
|
||||
expect(authViewModel.otpController.text, isEmpty);
|
||||
});
|
||||
|
||||
test('should initialize with password visibility obscured', () {
|
||||
expect(authViewModel.obscurePassword, true);
|
||||
expect(authViewModel.obscureForgotPassword, true);
|
||||
});
|
||||
|
||||
test('should not be login enabled with empty fields', () {
|
||||
expect(authViewModel.isLoginEnabled, false);
|
||||
});
|
||||
|
||||
test('should be login enabled with filled fields', () {
|
||||
authViewModel.usernameController.text = 'testuser';
|
||||
authViewModel.passwordController.text = 'testpass';
|
||||
|
||||
expect(authViewModel.isLoginEnabled, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user