import Foundation import Testing @testable import OrgCore struct ExportScopeTests { static let file = """ #+TITLE: Whole file #+AUTHOR: Ann #+OPTIONS: toc:nil num:nil * Intro Some intro. * TODO [#A] Project :work: SCHEDULED: <2026-10-10 Sat> :PROPERTIES: :EXPORT_FILE_NAME: project-notes :EXPORT_AUTHOR: Bob :END: Body of project. ** Step one Do it. *** Deep deep text * Other """ static var project: Int { (file as NSString).range(of: "Body of").location } /// As `org-export-as` with SUBTREEP in Emacs 31: the heading's title is the title, its /// EXPORT_AUTHOR the author; planning and drawer left out; children one level up. @Test func subtreeIsADocumentOfItsOwn() throws { let text = try #require(ExportScope.subtree(Self.file, at: Self.project)) #expect(text == """ #+TITLE: Whole file #+AUTHOR: Ann #+OPTIONS: toc:nil num:nil #+TITLE: Project #+AUTHOR: Bob Body of project. * Step one Do it. ** Deep deep text """) let meta = HTMLExport.metadata(text) #expect(meta.title == "Project" && meta.author == "Bob") let body = HTMLExport.page(text, fallbackTitle: "t", bodyOnly: true) #expect(!body.contains("