mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-26 16:46:51 +08:00
Fix tests
This commit is contained in:
@ -5,9 +5,12 @@ import 'package:test/test.dart';
|
||||
import 'package:gitjournal/core/md_yaml_doc.dart';
|
||||
import 'package:gitjournal/core/note.dart';
|
||||
import 'package:gitjournal/core/note_serializer.dart';
|
||||
import 'package:gitjournal/core/notes_folder_fs.dart';
|
||||
|
||||
void main() {
|
||||
group('Note Serializer Test', () {
|
||||
var parent = NotesFolderFS(null, '/tmp');
|
||||
|
||||
test('Test emojis', () {
|
||||
var props = LinkedHashMap<String, dynamic>.from(
|
||||
<String, dynamic>{"title": "Why not :coffee:?"});
|
||||
@ -16,7 +19,7 @@ void main() {
|
||||
var serializer = NoteSerializer.raw();
|
||||
serializer.settings.saveTitleAsH1 = false;
|
||||
|
||||
var note = Note(null, "file-path-not-important");
|
||||
var note = Note(parent, "file-path-not-important");
|
||||
serializer.decode(doc, note);
|
||||
|
||||
expect(note.body, "I ❤️ you");
|
||||
@ -37,7 +40,7 @@ void main() {
|
||||
var serializer = NoteSerializer.raw();
|
||||
serializer.settings.saveTitleAsH1 = true;
|
||||
|
||||
var note = Note(null, "file-path-not-important");
|
||||
var note = Note(parent, "file-path-not-important");
|
||||
serializer.decode(doc, note);
|
||||
|
||||
expect(note.body, "I ❤️ you");
|
||||
@ -57,7 +60,7 @@ void main() {
|
||||
|
||||
var serializer = NoteSerializer.raw();
|
||||
|
||||
var note = Note(null, "file-path-not-important");
|
||||
var note = Note(parent, "file-path-not-important");
|
||||
serializer.decode(doc, note);
|
||||
|
||||
expect(note.body, "I ❤️ you");
|
||||
@ -70,7 +73,7 @@ void main() {
|
||||
|
||||
var serializer = NoteSerializer.raw();
|
||||
|
||||
var note = Note(null, "file-path-not-important");
|
||||
var note = Note(parent, "file-path-not-important");
|
||||
serializer.decode(doc, note);
|
||||
|
||||
expect(note.body.length, 0);
|
||||
@ -85,7 +88,7 @@ void main() {
|
||||
var serializer = NoteSerializer.raw();
|
||||
serializer.settings.saveTitleAsH1 = true;
|
||||
|
||||
var note = Note(null, "file-path-not-important");
|
||||
var note = Note(parent, "file-path-not-important");
|
||||
serializer.decode(doc, note);
|
||||
|
||||
expect(note.body, "I ❤️ you");
|
||||
|
@ -6,6 +6,7 @@ import 'package:test/test.dart';
|
||||
|
||||
import 'package:gitjournal/core/md_yaml_doc.dart';
|
||||
import 'package:gitjournal/core/note.dart';
|
||||
import 'package:gitjournal/core/notes_folder_fs.dart';
|
||||
import 'package:gitjournal/utils/datetime.dart';
|
||||
|
||||
void main() {
|
||||
@ -26,11 +27,12 @@ void main() {
|
||||
n1Path = p.join(tempDir.path, "1.md");
|
||||
n2Path = p.join(tempDir.path, "2.md");
|
||||
|
||||
var n1 = Note(null, n1Path);
|
||||
var parent = NotesFolderFS(null, tempDir.path);
|
||||
var n1 = Note(parent, n1Path);
|
||||
n1.body = "test";
|
||||
n1.created = dt;
|
||||
|
||||
var n2 = Note(null, n2Path);
|
||||
var n2 = Note(parent, n2Path);
|
||||
n2.data = MdYamlDoc("test2", props);
|
||||
|
||||
notes = [n1, n2];
|
||||
@ -49,8 +51,10 @@ void main() {
|
||||
expect(File(n2Path).existsSync(), isTrue);
|
||||
|
||||
var loadedNotes = <Note>[];
|
||||
var parent = NotesFolderFS(null, tempDir.path);
|
||||
|
||||
await Future.forEach(notes, (origNote) async {
|
||||
var note = Note(null, origNote.filePath);
|
||||
var note = Note(parent, origNote.filePath);
|
||||
var r = await note.load();
|
||||
expect(r, NoteLoadState.Loaded);
|
||||
|
||||
|
Reference in New Issue
Block a user