Files
tm_app/test/model/onboarding_response_test.dart
T
AmirReza Jamali 50e4f43738 feat: add AI recommendations flow for tenders
Implement company AI onboarding/recommendation models, services, repository, and tender UI integration with supporting tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 11:47:52 +03:30

52 lines
1.7 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:tm_app/data/services/model/onboarding_response/onboarding_response.dart';
void main() {
group('OnboardingResponse Model Test', () {
final mockJson = {
'success': true,
'message': 'AI onboarding started successfully',
'data': {'status': 'started'},
'error': {'message': null, 'code': null, 'details': null},
};
test('fromJson creates valid OnboardingResponse instance', () {
final response = OnboardingResponse.fromJson(mockJson);
expect(response.success, true);
expect(response.message, 'AI onboarding started successfully');
expect(response.data?.status, 'started');
});
test('handles null data gracefully', () {
final response = OnboardingResponse.fromJson({
'success': false,
'message': 'AI service not configured',
'data': null,
'error': {'message': 'unavailable', 'code': '503', 'details': null},
});
expect(response.success, false);
expect(response.data, isNull);
expect(response.error?.message, 'unavailable');
});
test('toJson round-trips status', () {
final response = OnboardingResponse.fromJson(mockJson);
final json = response.toJson();
final data = Map<String, dynamic>.from(json['data'] as Map);
expect(json['success'], true);
expect(data['status'], 'started');
});
test('equality and copyWith work as expected', () {
final response = OnboardingResponse.fromJson(mockJson);
final updated = response.copyWith(message: 'Updated');
expect(updated.message, 'Updated');
expect(updated != response, true);
});
});
}