mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-15 07:56:11 +08:00
checklist: verify insertItem works
This commit is contained in:
@ -113,7 +113,7 @@ class Checklist {
|
||||
var prevItem = items[index];
|
||||
var nodeIndex = nodes.indexOf(prevItem.element);
|
||||
|
||||
nodes.insert(nodeIndex + 1, item.element);
|
||||
nodes.insert(nodeIndex, item.element);
|
||||
items.insert(index, item);
|
||||
}
|
||||
}
|
||||
|
@ -149,5 +149,25 @@ Booga Wooga
|
||||
note = checklist.note;
|
||||
expect(note.body, "Hi.\n[ ] item\n");
|
||||
});
|
||||
|
||||
test('insertItem works', () async {
|
||||
var content = "Hi.\n[ ] One\nTwo\n[ ] Three";
|
||||
|
||||
var notePath = p.join(tempDir.path, "note4.md");
|
||||
File(notePath).writeAsString(content);
|
||||
|
||||
var parentFolder = NotesFolder(null, tempDir.path);
|
||||
var note = Note(parentFolder, notePath);
|
||||
await note.load();
|
||||
|
||||
var checklist = Checklist(note);
|
||||
var items = checklist.items;
|
||||
expect(items.length, equals(2));
|
||||
|
||||
checklist.insertItem(1, checklist.buildItem(false, "item"));
|
||||
|
||||
note = checklist.note;
|
||||
expect(note.body, "Hi.\n[ ] One\nTwo\n[ ] item\n[ ] Three\n");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user