41 lines
1.3 KiB
Dart
41 lines
1.3 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:tm_app/data/services/model/home/home_request/home_request_model.dart';
|
|
|
|
void main() {
|
|
group('HomeRequestModel Tests', () {
|
|
final mockJson = {'id': 'home_123'};
|
|
|
|
test('fromJson creates valid instance', () {
|
|
final model = HomeRequestModel.fromJson(mockJson);
|
|
|
|
expect(model.id, 'home_123');
|
|
});
|
|
|
|
test('toJson converts model back to JSON correctly', () {
|
|
final model = const HomeRequestModel(id: 'home_123');
|
|
final json = model.toJson();
|
|
|
|
expect(json, isA<Map<String, dynamic>>());
|
|
expect(json['id'], 'home_123');
|
|
});
|
|
|
|
test('copyWith correctly updates id', () {
|
|
final model = const HomeRequestModel(id: 'home_123');
|
|
final updated = model.copyWith(id: 'home_456');
|
|
|
|
expect(updated.id, 'home_456');
|
|
expect(updated, isNot(equals(model)));
|
|
});
|
|
|
|
test('equality operator works correctly', () {
|
|
final model1 = const HomeRequestModel(id: 'home_123');
|
|
final model2 = const HomeRequestModel(id: 'home_123');
|
|
final model3 = const HomeRequestModel(id: 'different_id');
|
|
|
|
expect(model1, equals(model2));
|
|
expect(model1.hashCode, equals(model2.hashCode));
|
|
expect(model1, isNot(equals(model3)));
|
|
});
|
|
});
|
|
}
|