Files
tdc114plus/app/test/models/directory_models_test.dart
T
2026-07-02 13:00:17 +09:00

64 lines
1.8 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:tdc114plus/src/features/directory/domain/employee.dart';
void main() {
test('EmployeeListResponse parses paginated employee list', () {
final response = EmployeeListResponse.fromJson({
'items': [
{
'id': 'user-uuid',
'name': 'User One',
'phoneNumber': '+821012345678',
'phoneDisplay': '010-1234-5678',
'email': 'user@example.com',
'tenantId': 'tenant-uuid',
'tenantName': 'Hanmac',
'tenantSlug': 'hanmac',
'department': 'Engineering',
'grade': 'Lead',
'position': 'Manager',
'jobTitle': 'Developer',
'status': 'active',
'profileImageUrl': null,
'sortOrder': 100,
},
],
'limit': 50,
'offset': 0,
'total': 1,
'nextCursor': '',
});
expect(response.items, hasLength(1));
expect(response.items.first.phoneDisplay, '010-1234-5678');
expect(response.total, 1);
});
test('EmployeeDetail parses joined tenants and available actions', () {
final detail = EmployeeDetail.fromJson({
'id': 'user-uuid',
'name': 'User One',
'phoneNumber': '+821012345678',
'email': 'user@example.com',
'tenantId': 'tenant-uuid',
'tenantName': 'Hanmac',
'tenantSlug': 'hanmac',
'joinedTenants': [
{
'id': 'tenant-uuid',
'name': 'Hanmac',
'slug': 'hanmac',
'type': 'COMPANY',
'parentId': 'root-tenant-uuid',
},
],
'status': 'active',
'actions': {'call': true, 'sms': true, 'email': true},
});
expect(detail.joinedTenants.first.type, 'COMPANY');
expect(detail.actions.call, isTrue);
expect(detail.actions.sms, isTrue);
});
}