mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 17:29:50 +08:00
Handle empty checklists
If there were no items we were ignoring the checklist. Added some extra tests as well. Fixes #148
This commit is contained in:
@ -91,8 +91,6 @@ class Checklist {
|
||||
}
|
||||
|
||||
Note get note {
|
||||
if (_lines.isEmpty) return _note;
|
||||
|
||||
for (var item in items) {
|
||||
_lines[item.lineNo] = item.toString();
|
||||
}
|
||||
|
@ -238,5 +238,39 @@ Booga Wooga
|
||||
note = checklist.note;
|
||||
expect(note.body, "- [X] One\n- [ ] Two");
|
||||
});
|
||||
|
||||
test('Empty Checklist', () async {
|
||||
var content = "[X] One\n";
|
||||
|
||||
var notePath = p.join(tempDir.path, "note449.md");
|
||||
await File(notePath).writeAsString(content);
|
||||
|
||||
var parentFolder = NotesFolderFS(null, tempDir.path);
|
||||
var note = Note(parentFolder, notePath);
|
||||
await note.load();
|
||||
|
||||
var checklist = Checklist(note);
|
||||
checklist.removeAt(0);
|
||||
|
||||
note = checklist.note;
|
||||
expect(note.body, "\n");
|
||||
});
|
||||
|
||||
test('Checklist Header only', () async {
|
||||
var content = "#Title\n[X] One\n";
|
||||
|
||||
var notePath = p.join(tempDir.path, "note429.md");
|
||||
await File(notePath).writeAsString(content);
|
||||
|
||||
var parentFolder = NotesFolderFS(null, tempDir.path);
|
||||
var note = Note(parentFolder, notePath);
|
||||
await note.load();
|
||||
|
||||
var checklist = Checklist(note);
|
||||
checklist.removeAt(0);
|
||||
|
||||
note = checklist.note;
|
||||
expect(note.body, "#Title\n");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user