Tests/OrgAppTests/PDFExportTests.swift

eb700e67391c27d460f7c452d97d4020e4f4f021
orgstar/Tests/OrgAppTests/PDFExportTests.swift

21 lines · 964 bytes

 1import Foundation
 2import OrgCore
 3import PDFKit
 4import Testing
 5@testable import OrgApp
 6
 7@MainActor
 8struct PDFExportTests {
 9    /// A long document comes out as several pages with its text, without Emacs.
10    @Test func paginatesTheHTMLExport() async throws {
11        let sections = (1...40).map { "* Section \($0)\n" + String(repeating: "Some words in a paragraph. ", count: 30) + "\n" }.joined()
12        let html = HTMLExport.page("#+TITLE: Long\n" + sections + "#+begin_src sh\necho done\n#+end_src\n", fallbackTitle: "t")
13        let data = try await PDFExport.pdf(html: html, directory: nil)
14        let document = try #require(PDFDocument(data: data))
15        #expect(document.pageCount > 3)
16        let text = document.string ?? ""
17        #expect(text.contains("Long") && text.contains("Section 40") && text.contains("echo done"))
18        let page = try #require(document.page(at: 0)).bounds(for: .mediaBox)
19        #expect(page.width < page.height)
20    }
21}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form