Tests/OrgPresentationTests/TagGapTests.swift
23 lines · 1090 bytes
3 symbols in this file
1import Foundation
2import OrgCore
3import Testing
4@testable import OrgPresentation
5
6struct TagGapTests {
7 @Test func aPaddedHeadingHasAGap() {
8 let text = "* TODO Call :office:\n** Short :a:b:\n* Tab\t :x:\n*** Deep :y:\n"
9 let gaps = Presentation.tagGaps(OrgParser.parse(text))
10 let ns = text as NSString
11 #expect(gaps.map { ns.substring(with: NSRange($0.gap)) } == [" ", " "])
12 #expect(gaps.map { ns.substring(with: NSRange($0.tags)) } == [":office:", ":y:"])
13 }
14
15 @Test func theGapFitsTheWidth() {
16 // As written when the line fits, as on a wide Mac window.
17 #expect(Presentation.tagGapWidth(title: 100, gap: 300, space: 7, tags: 50, available: 500) == nil)
18 // The tags at the right edge when only the padding doesn't fit.
19 #expect(Presentation.tagGapWidth(title: 100, gap: 300, space: 7, tags: 50, available: 300) == 150)
20 // One space when the title and tags don't fit on the line.
21 #expect(Presentation.tagGapWidth(title: 280, gap: 300, space: 7, tags: 50, available: 300) == 7)
22 }
23}