Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions carp_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.9.4

* fix of issue [#506](https://github.com/cph-cachet/carp.sensing-flutter/issues/506)
* added unit tests for input data types

## 1.9.3

* fix of issue [#491](https://github.com/cph-cachet/carp.sensing-flutter/issues/491)
Expand Down
1 change: 1 addition & 0 deletions carp_core/lib/carp_core.json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ void _registerFromJsonFunctions() {
SexInput(value: Sex.Female),
FullNameInput(),
AddressInput(),
PhoneNumberInput(countryCode: '', number: ''),
SocialSecurityNumberInput(socialSecurityNumber: '', country: ''),
InformedConsentInput(name: '', userId: '', consent: '', signatureImage: ''),
DiagnosisInput(icd11Code: ''),
Expand Down
2 changes: 1 addition & 1 deletion carp_core/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: carp_core
description: The core domain model for the Copenhagen Research Platform (CARP) in Dart.
version: 1.9.3
version: 1.9.4
homepage: https://github.com/cph-cachet/carp.sensing-flutter

environment:
Expand Down
84 changes: 84 additions & 0 deletions carp_core/test/carp_core_dart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,88 @@ void main() {
expect(task.getUrl('12345-1234', 'ecec573e-442b-4563-8e2c-62b7693011df', 1),
'https://cans.cachet.dk/portal/playground/studies/ecec573e-442b-4563-8e2c-62b7693011df/settings?participant=12345-1234&trigger_id=1');
});

group('InputData - deep assert', () {
test('- CustomInput', () async {
final dataJson = toJsonString(CustomInput(value: {'key': 'value'}));

final dataFromJson =
CustomInput.fromJson(json.decode(dataJson) as Map<String, dynamic>);
print(toJsonString(dataFromJson));
expect(toJsonString(dataFromJson), equals(dataJson));
});

test('- SexInput', () async {
final dataJson = toJsonString(SexInput(value: Sex.Male));

final dataFromJson =
SexInput.fromJson(json.decode(dataJson) as Map<String, dynamic>);
print(toJsonString(dataFromJson));
expect(toJsonString(dataFromJson), equals(dataJson));
});

test('- PhoneNumberInput', () async {
final dataJson = toJsonString(
PhoneNumberInput(countryCode: '+45', number: '12345678'));

final dataFromJson = PhoneNumberInput.fromJson(
json.decode(dataJson) as Map<String, dynamic>);
print(toJsonString(dataFromJson));
expect(toJsonString(dataFromJson), equals(dataJson));
});

test('- SocialSecurityNumberInput', () async {
final dataJson = toJsonString(SocialSecurityNumberInput(
country: '45', socialSecurityNumber: '123456-7890'));

final dataFromJson = SocialSecurityNumberInput.fromJson(
json.decode(dataJson) as Map<String, dynamic>);
print(toJsonString(dataFromJson));
expect(toJsonString(dataFromJson), equals(dataJson));
});

test('- FullNameInput', () async {
final dataJson = toJsonString(
FullNameInput(firstName: 'John', middleName: 'A.', lastName: 'Doe'));

final dataFromJson =
FullNameInput.fromJson(json.decode(dataJson) as Map<String, dynamic>);
print(toJsonString(dataFromJson));
expect(toJsonString(dataFromJson), equals(dataJson));
});

test('- AddressInput', () async {
final dataJson =
toJsonString(AddressInput(street: 'Main St', city: 'Anytown'));

final dataFromJson =
AddressInput.fromJson(json.decode(dataJson) as Map<String, dynamic>);
print(toJsonString(dataFromJson));
expect(toJsonString(dataFromJson), equals(dataJson));
});

test('- DiagnosisInput', () async {
final dataJson =
toJsonString(DiagnosisInput(diagnosis: 'Flu', icd11Code: '123456'));

final dataFromJson = DiagnosisInput.fromJson(
json.decode(dataJson) as Map<String, dynamic>);
print(toJsonString(dataFromJson));
expect(toJsonString(dataFromJson), equals(dataJson));
});

test('- InformedConsentInput', () async {
final dataJson = toJsonString(InformedConsentInput(
userId: '12345',
name: 'John Doe',
consent: 'true',
signatureImage: 'blob',
));

final dataFromJson = InformedConsentInput.fromJson(
json.decode(dataJson) as Map<String, dynamic>);
print(toJsonString(dataFromJson));
expect(toJsonString(dataFromJson), equals(dataJson));
});
});
}