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}