Files
i7t5--edmund/Tests/EdmundTests/ReferenceLinkIntegrationTests.swift
wehub-resource-sync 5b99bf6bca
CI / test (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:34:54 +08:00

36 lines
1.4 KiB
Swift

import Testing
import AppKit
@testable import EdmundCore
// Cross-block reference-link resolution in the live editor. "use [foo] here" is
// block 0; the definition is block 2. Activating block 2 leaves block 0 styled,
// so its `[foo]` must resolve against a definition parsed from another block.
// 'f' of "foo" sits at offset 5.
@Suite("Integration — Reference links")
struct ReferenceLinkIntegrationTests {
@Test("A shortcut reference resolves against a definition in another block")
@MainActor func crossBlockResolves() {
let editor = makeEditor()
editor.loadContent("use [foo] here\n\n[foo]: https://e.com")
activateBlock(2, in: editor)
#expect(fgColor(at: 5, in: editor) == editor.linkColor)
}
@Test("With no matching definition the same text stays plain (not a link)")
@MainActor func noDefinitionStaysPlain() {
let editor = makeEditor()
editor.loadContent("use [foo] here\n\nprose only")
activateBlock(2, in: editor)
#expect(fgColor(at: 5, in: editor) != editor.linkColor)
}
@Test("A definition inside a block quote resolves a use in another block")
@MainActor func definitionInsideBlockQuoteResolves() {
let editor = makeEditor()
editor.loadContent("use [foo] here\n\n> [foo]: https://e.com")
activateBlock(2, in: editor)
#expect(fgColor(at: 5, in: editor) == editor.linkColor)
}
}