import 'package:flutter_test/flutter_test.dart'; import 'package:tm_app/data/services/model/company_profile_data/company_profile_data.dart'; import 'package:tm_app/data/services/model/company_profile_response/company_profile_response.dart'; import 'package:tm_app/data/services/model/error/error_model.dart'; void main() { group('CompanyProfileData Model Tests', () { test('fromJson should parse JSON correctly', () { final json = { 'id': '1', 'name': 'OpenAI', 'registration_number': '12345', 'industry': 'AI Research', 'founded_year': 2015, 'created_at': 1700000000, }; final data = CompanyProfileData.fromJson(json); expect(data.id, '1'); expect(data.name, 'OpenAI'); expect(data.registrationNumber, '12345'); expect(data.foundedYear, 2015); expect(data.createdAt, 1700000000); }); test('toJson should return valid JSON', () { final data = const CompanyProfileData( id: '2', name: 'Flutter Inc', registrationNumber: '98765', industry: 'Software', foundedYear: 2017, createdAt: 1800000000, ); final json = data.toJson(); expect(json['id'], '2'); expect(json['registration_number'], '98765'); expect(json['industry'], 'Software'); }); test('copyWith should return a modified object', () { final data = const CompanyProfileData( id: '1', name: 'OldName', registrationNumber: '123', industry: 'Tech', foundedYear: 2020, createdAt: 1600000000, ); final updated = data.copyWith(name: 'NewName'); expect(updated.name, 'NewName'); expect(updated.industry, 'Tech'); }); }); group('CompanyProfileResponse Model Tests', () { test('fromJson should parse nested JSON correctly', () { final json = { 'message': 'Success', 'success': true, 'error': {'code': '0', 'message': 'No error', 'details': 'details'}, 'data': { 'id': '10', 'name': 'AI Labs', 'registration_number': 'A123', 'industry': 'AI', 'founded_year': 2020, 'created_at': 1700000000, }, }; final response = CompanyProfileResponse.fromJson(json); expect(response.message, 'Success'); expect(response.success, true); expect(response.data?.name, 'AI Labs'); expect(response.data?.foundedYear, 2020); }); test('toJson should return valid JSON map', () { final data = const CompanyProfileData( id: '3', name: 'NeuralNet', registrationNumber: 'B456', industry: 'ML', foundedYear: 2019, createdAt: 1750000000, ); final response = CompanyProfileResponse( message: 'Success', success: true, error: const ErrorModel( code: '0', message: 'No error', details: 'details', ), data: data, ); final json = response.toJson(); expect(json['message'], 'Success'); expect(json['success'], true); expect(response.data?.name, 'NeuralNet'); }); test('copyWith should modify only specific fields', () { final response = const CompanyProfileResponse( message: 'Old message', success: false, error: null, data: null, ); final updated = response.copyWith(message: 'New message', success: true); expect(updated.message, 'New message'); expect(updated.success, true); expect(updated.data, null); }); }); }