forked from eatvio/eatvio_app
feat(tests): add fixtures
This commit is contained in:
@@ -2,24 +2,27 @@
|
||||
|
||||
import 'package:eatvio_app/app_keys.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/auth/models/token_model.dart';
|
||||
import 'package:eatvio_app/features/auth/presentation/bloc/auth_cubit/auth_cubit.dart';
|
||||
import 'package:eatvio_app/features/auth/repositories/auth_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
|
||||
import 'basic_widget_test.mocks.dart';
|
||||
import '../../../../fixtures/doubles/auth_doubles.dart';
|
||||
import '../../../../fixtures/fixture_reader.dart';
|
||||
|
||||
@GenerateMocks([AuthRepository])
|
||||
void main() {
|
||||
group('Auth Basic Widget Tests', () {
|
||||
late MockAuthRepository mockAuthRepository;
|
||||
late FixtureAuthRepository authRepository;
|
||||
late AuthCubit authCubit;
|
||||
late Map<String, dynamic> credentialsFixture;
|
||||
|
||||
setUp(() {
|
||||
mockAuthRepository = MockAuthRepository();
|
||||
authCubit = AuthCubit(authRepository: mockAuthRepository);
|
||||
credentialsFixture = FixtureReader.readAsMap('auth/login_credentials.json');
|
||||
authRepository = FixtureAuthRepository(
|
||||
tokenFixture: TokenModel.fromJson(FixtureReader.readAsMap('auth/token_response.json')),
|
||||
);
|
||||
authCubit = AuthCubit(authRepository: authRepository);
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
@@ -38,7 +41,7 @@ void main() {
|
||||
|
||||
testWidgets('should create AuthCubit successfully', (WidgetTester tester) async {
|
||||
// Arrange & Act
|
||||
final cubit = AuthCubit(authRepository: mockAuthRepository);
|
||||
final cubit = AuthCubit(authRepository: authRepository);
|
||||
|
||||
// Assert
|
||||
expect(cubit, isA<AuthCubit>());
|
||||
@@ -106,7 +109,7 @@ void main() {
|
||||
await tester.pumpWidget(createTestWidget(emailWidget));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
const testEmail = 'test@example.com';
|
||||
final testEmail = credentialsFixture['email'] as String;
|
||||
|
||||
// Act
|
||||
await tester.enterText(find.byKey(AppKeys.emailTextFieldAuthScreen), testEmail);
|
||||
@@ -127,7 +130,7 @@ void main() {
|
||||
await tester.pumpWidget(createTestWidget(passwordWidget));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
const testPassword = 'password123';
|
||||
final testPassword = credentialsFixture['password'] as String;
|
||||
|
||||
// Act
|
||||
await tester.enterText(find.byKey(AppKeys.passwordTextFieldAuthScreen), testPassword);
|
||||
|
||||
Reference in New Issue
Block a user