Tests/OrgCoreTests/InlineImagesTests.swift

ed6b554dc7b2806d081a993284d03064ec2ff7f2
orgstar/Tests/OrgCoreTests/InlineImagesTests.swift

16 lines · 964 bytes

 1import Foundation
 2import Testing
 3@testable import OrgCore
 4
 5struct InlineImagesTests {
 6    @Test func findsImageLines() {
 7        let text = "#+STARTUP: inlineimages\n* Images\n[[file:pic.png]]\n#+NAME: x\n#+ATTR_ORG: :width 60\n[[./pic.png]]\n[[pic.png][desc]]\nAfter [[pic.png]] text\n[[https://x.org/a.png]]\n" as NSString
 8        func at(_ s: String) -> InlineImages.Image? { InlineImages.image(atLine: text.range(of: s).location, in: text) }
 9        #expect(at("[[file:pic") == InlineImages.Image(path: "pic.png", width: nil))
10        #expect(at("[[./pic") == InlineImages.Image(path: "./pic.png", width: 60))
11        #expect(at("[[pic.png][") == nil && at("After") == nil && at("[[https") == nil)
12        #expect(InlineImages.startup(OrgParser.parse(text as String)) == true)
13        #expect(InlineImages.startup(OrgParser.parse("#+STARTUP: overview noinlineimages\n")) == false)
14        #expect(InlineImages.startup(OrgParser.parse("* x\n")) == nil)
15    }
16}
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