Tests/OrgPresentationTests/TagGapTests.swift

6e76718b67275264fce9c9041e50ec01592edace
orgstar/Tests/OrgPresentationTests/TagGapTests.swift

23 lines · 1090 bytes

 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}
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