Tests/OrgPresentationTests/MixedPitchTests.swift
33 lines · 1333 bytes
5 symbols in this file
1import Foundation
2import OrgCore
3import Testing
4@testable import OrgPresentation
5
6struct MixedPitchTests {
7 @Test func fixedPitchRoles() {
8 for role: StyleRole in [.table, .rule, .block, .blockDelimiter, .verbatim, .code, .inlineSource, .metadata, .keyword, .tags, .timestamp, .syntax(.keyword)] {
9 #expect(Presentation.isFixedPitch(role), "\(role)")
10 }
11 for role: StyleRole in [.heading(level: 1), .bold, .italic, .link, .comment, .todo, .markup, .footnote] {
12 #expect(!Presentation.isFixedPitch(role), "\(role)")
13 }
14 }
15
16 @Test func prefixesThatSetIndentation() {
17 let text = "** Heading\nProse here.\n indented prose\n- item\n - [ ] box\n12. twelve\n\tTabbed\n*bold* not a heading\n" as NSString
18 let prefixes = Presentation.fixedPitchPrefixes(text, in: 0..<text.length).map { text.substring(with: NSRange($0)) }
19 #expect(prefixes == ["** ", " ", "- ", " - [ ] ", "12. ", "\t"])
20 }
21
22 @Test func prefixesOnlyInRange() {
23 let text = "- a\n- b\n" as NSString
24 #expect(Presentation.fixedPitchPrefixes(text, in: 4..<8) == [4..<6])
25 }
26
27 @Test func bodyFontInSpec() {
28 var spec = ThemeSpec.default
29 #expect(spec.bodyFont.isEmpty)
30 spec.bodyFont = "system"
31 #expect(spec != ThemeSpec.default)
32 }
33}