Task edit #37

Open
konrad wants to merge 76 commits from feature/edit-task into master
2 changed files with 25 additions and 6 deletions
Showing only changes of commit 0b06fc3beb - Show all commits

View File

@ -38,12 +38,10 @@ class Task {
text = inp['text'],
description = inp['description'],
done = inp['done'],
reminderDates = inp['reminderDates'] == null
? null
: (inp['reminderDates'] as List<dynamic>)
.map((ts) => dateTimeFromUnixTimestamp(ts))
.cast<DateTime>()
.toList(),
reminderDates = (inp['reminderDates'] as List<dynamic>)
?.map((ts) => dateTimeFromUnixTimestamp(ts))
?.cast<DateTime>()
?.toList(),
dueDate = dateTimeFromUnixTimestamp(inp['dueDate']),
startDate = dateTimeFromUnixTimestamp(inp['startDate']),
endDate = dateTimeFromUnixTimestamp(inp['endDate']),

View File

@ -28,4 +28,25 @@ void main() {
expect(task.created, DateTime.fromMillisecondsSinceEpoch(1542465818 * 1000));
expect(task.updated, DateTime.fromMillisecondsSinceEpoch(1552771527 * 1000));
});
test('Check encoding with reminder dates as null', () {
final String json = '{"id": 1,"text": "test","description": "Lorem Ipsum","done": true,"dueDate": 1543834800,"reminderDates": null,"repeatAfter": 3600,"parentTaskID": 0,"priority": 100,"startDate": 1543834800,"endDate": 1543835000,"assignees": null,"labels": null,"subtasks": null,"created": 1542465818,"updated": 1552771527,"createdBy": {"id": 4,"username": "konrad","email": "vikunjatry@kolaente.de","created": 1537855131,"updated": 1545233325}}';
final JsonDecoder _decoder = new JsonDecoder();
final task = Task.fromJson(_decoder.convert(json));
expect(task.id, 1);
expect(task.text, 'test');
expect(task.description, 'Lorem Ipsum');
expect(task.done, true);
expect(task.reminderDates, null);
expect(task.dueDate, DateTime.fromMillisecondsSinceEpoch(1543834800 * 1000));
expect(task.repeatAfter, Duration(seconds: 3600));
expect(task.parentTaskID, 0);
expect(task.priority, 100);
expect(task.startDate, DateTime.fromMillisecondsSinceEpoch(1543834800 * 1000));
expect(task.endDate, DateTime.fromMillisecondsSinceEpoch(1543835000 * 1000));
expect(task.labels, null);
expect(task.subtasks, null);
expect(task.created, DateTime.fromMillisecondsSinceEpoch(1542465818 * 1000));
expect(task.updated, DateTime.fromMillisecondsSinceEpoch(1552771527 * 1000));
});
}