59 lines
1.6 KiB
Dart
59 lines
1.6 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:tm_app/data/services/model/company_profile_data/company_profile_data.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');
|
|
});
|
|
});
|
|
}
|