import 'package:eatvio_app/features/auth/models/oauth_verification_confirm_request.dart'; import 'package:eatvio_app/features/auth/models/oauth_verification_confirm_response.dart'; import 'package:eatvio_app/features/auth/models/oauth_verification_request_response.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { group('OAuthVerificationRequestResponse', () { test('fromJson parses JSON correctly', () { final json = {'email': 'test@example.com', 'status': 'pending'}; final response = OAuthVerificationRequestResponse.fromJson(json); expect(response.email, 'test@example.com'); expect(response.status, 'pending'); }); test('toJson serializes correctly', () { const response = OAuthVerificationRequestResponse(email: 'test@example.com', status: 'pending'); final json = response.toJson(); expect(json['email'], 'test@example.com'); expect(json['status'], 'pending'); }); }); group('OAuthVerificationConfirmRequest', () { test('fromJson parses JSON correctly', () { final json = { 'access_token': 'access123', 'refresh_token': 'refresh123', 'client_id': 'client123', 'provider': 'google', 'id': 'user123', 'email': 'test@example.com', 'phone': '+1234567890', 'code': 'verification_code', 'verification_type': 'email', 'first_name': 'John', 'last_name': 'Doe', 'date_of_birth': '1990-01-01', 'gender': 'male', 'weight': 75, 'height': 180, }; final request = OAuthVerificationConfirmRequest.fromJson(json); expect(request.accessToken, 'access123'); expect(request.refreshToken, 'refresh123'); expect(request.clientId, 'client123'); expect(request.provider, 'google'); expect(request.id, 'user123'); expect(request.email, 'test@example.com'); expect(request.phone, '+1234567890'); expect(request.code, 'verification_code'); expect(request.verificationType, 'email'); expect(request.firstName, 'John'); expect(request.lastName, 'Doe'); expect(request.dateOfBirth, '1990-01-01'); expect(request.gender, 'male'); expect(request.weight, 75); expect(request.height, 180); }); test('fromJson handles optional fields', () { final json = { 'access_token': 'access123', 'refresh_token': 'refresh123', 'client_id': 'client123', 'provider': 'google', 'id': 'user123', 'code': 'verification_code', 'verification_type': 'email', 'first_name': 'John', 'last_name': 'Doe', 'date_of_birth': '1990-01-01', 'gender': 'male', 'weight': 75, 'height': 180, }; final request = OAuthVerificationConfirmRequest.fromJson(json); expect(request.email, isNull); expect(request.phone, isNull); }); test('toJson serializes correctly', () { const request = OAuthVerificationConfirmRequest( accessToken: 'access123', refreshToken: 'refresh123', clientId: 'client123', provider: 'google', id: 'user123', email: 'test@example.com', phone: '+1234567890', code: 'verification_code', verificationType: 'email', firstName: 'John', lastName: 'Doe', dateOfBirth: '1990-01-01', gender: 'male', weight: 75, height: 180, ); final json = request.toJson(); expect(json['access_token'], 'access123'); expect(json['refresh_token'], 'refresh123'); expect(json['client_id'], 'client123'); expect(json['provider'], 'google'); expect(json['id'], 'user123'); expect(json['email'], 'test@example.com'); expect(json['phone'], '+1234567890'); expect(json['code'], 'verification_code'); expect(json['verification_type'], 'email'); expect(json['first_name'], 'John'); expect(json['last_name'], 'Doe'); expect(json['date_of_birth'], '1990-01-01'); expect(json['gender'], 'male'); expect(json['weight'], 75); expect(json['height'], 180); }); }); group('OAuthVerificationConfirmResponse', () { test('fromJson parses JSON correctly', () { final json = { 'success': true, 'message': 'Verification successful', 'token': 'auth_token_123', 'user': {'id': 1, 'name': 'John Doe'}, 'is_new_user': true, }; final response = OAuthVerificationConfirmResponse.fromJson(json); expect(response.success, isTrue); expect(response.message, 'Verification successful'); expect(response.token, 'auth_token_123'); expect(response.user['id'], 1); expect(response.user['name'], 'John Doe'); expect(response.isNewUser, isTrue); }); test('toJson serializes correctly', () { const response = OAuthVerificationConfirmResponse( success: true, message: 'Verification successful', token: 'auth_token_123', user: {'id': 1, 'name': 'John Doe'}, isNewUser: false, ); final json = response.toJson(); expect(json['success'], isTrue); expect(json['message'], 'Verification successful'); expect(json['token'], 'auth_token_123'); expect(json['user']['id'], 1); expect(json['user']['name'], 'John Doe'); expect(json['is_new_user'], isFalse); }); }); }