From 33e1f0dca60dbe4e0bf818a9d9caff7b465f6e35 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 21 Dec 2020 21:35:51 -0500 Subject: [PATCH] Add Document.title test --- GeminiFormatTests/DocumentTests.swift | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/GeminiFormatTests/DocumentTests.swift b/GeminiFormatTests/DocumentTests.swift index 0096f1e..c6fab83 100644 --- a/GeminiFormatTests/DocumentTests.swift +++ b/GeminiFormatTests/DocumentTests.swift @@ -52,5 +52,29 @@ test > quoted """) } + + func testGetTitle() { + let h1 = Document(url: URL(string: "gemini://example.com/")!, lines: [ + .heading("Test", level: .h1) + ]) + XCTAssertEqual(h1.title, "Test") + + let h2 = Document(url: URL(string: "gemini://example.com/")!, lines: [ + .heading("Test", level: .h2) + ]) + XCTAssertEqual(h2.title, "Test") + + let h3 = Document(url: URL(string: "gemini://example.com/")!, lines: [ + .heading("Test", level: .h3) + ]) + XCTAssertEqual(h3.title, "Test") + + let multiple = Document(url: URL(string: "gemini://example.com/")!, lines: [ + .heading("Two", level: .h2), + .heading("One", level: .h1), + .heading("Three", level: .h3), + ]) + XCTAssertEqual(multiple.title, "Two") + } }