import Foundation import Testing @testable import NorgKit struct NorgDocumentTests { @Test func defaultsToEmptyBlocks() { #expect(NorgDocument().blocks.isEmpty) } @Test func treeFoldsBlocksIntoNodes() { let doc = NorgDocument(blocks: [ .heading(level: 1, status: nil, content: [InlineSpan(text: "H")], line: 0), .paragraph(content: [InlineSpan(text: "body")], line: 1), ]) let tree = doc.tree() #expect(tree.count == 1) #expect(tree.first?.children.count == 1) } @Test func treeMatchesTreeFolderOutput() { let doc = NorgParser.parse("* H\n- a\n-- b") #expect(doc.tree() == TreeFolder(doc.blocks).fold()) } @Test func roundTripsThroughJSON() throws { let doc = NorgParser.parse("* H\nbody\n- ( ) task") let data = try JSONEncoder().encode(doc) #expect(try JSONDecoder().decode(NorgDocument.self, from: data) == doc) } }