-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathrecipient_details_dto_test.dart
More file actions
58 lines (51 loc) · 1.96 KB
/
Copy pathrecipient_details_dto_test.dart
File metadata and controls
58 lines (51 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import 'package:bb_mobile/features/recipients/application/dtos/recipient_details_dto.dart';
import 'package:bb_mobile/features/recipients/domain/value_objects/recipient_details.dart';
import 'package:bb_mobile/features/recipients/domain/value_objects/recipient_type.dart';
import 'package:bb_mobile/features/recipients/interface_adapters/presenters/models/recipient_view_model.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('nullable SINPE owner name', () {
test('mobile recipient remains valid without an owner name', () {
const dto = RecipientDetailsDto(
recipientType: RecipientType.sinpeMovilCrc,
phoneNumber: '8888-8888',
);
final details = dto.toDomain() as SinpeMovilCrcDetails;
expect(details.phoneNumber, '8888-8888');
expect(details.ownerName, isNull);
});
test('IBAN recipients remain valid without an owner name', () {
for (final type in [
RecipientType.sinpeIbanCrc,
RecipientType.sinpeIbanUsd,
]) {
final dto = RecipientDetailsDto(
recipientType: type,
iban: 'CR05015202001026284066',
);
final details = dto.toDomain();
final ownerName = switch (details) {
SinpeIbanCrcDetails(:final ownerName) => ownerName,
SinpeIbanUsdDetails(:final ownerName) => ownerName,
_ => throw StateError('Unexpected details type'),
};
expect(ownerName, isNull);
}
});
test('display name falls back to label then identifier', () {
const labeled = RecipientViewModel(
id: 'recipient-1',
type: RecipientType.sinpeMovilCrc,
label: 'Family',
phoneNumber: '8888-8888',
);
const unlabeled = RecipientViewModel(
id: 'recipient-2',
type: RecipientType.sinpeMovilCrc,
phoneNumber: '8888-8888',
);
expect(labeled.displayName, 'Family');
expect(unlabeled.displayName, '8888-8888');
});
});
}