Files
Puranjay Savar Mattas 6e1ffb96fd chore: vendor swift-markdown-engine as plain tracked source
Convert from git submodule to plain vendored copy. No push access to
upstream nodes-app/swift-markdown-engine meant our local fix commit
(05c1720) was stranded and unreachable from any remote on fresh
clones/CI. Vendoring as plain files folds it into normal repo history
instead.
2026-08-20 13:26:13 +01:00

49 lines
1.6 KiB
Swift

//
// TableWidthChangeRestyleTests.swift
// MarkdownEngine
//
import AppKit
import Foundation
import Testing
@testable import MarkdownEngine
@Suite("Table width-change restyling")
struct TableWidthChangeRestyleTests {
@Test("Initially narrow tables stamp their paragraph for width-change restyling")
func narrowTableStampsWidthChangeRange() throws {
_ = NSApplication.shared
let text = "| a | b |\n|---|---|\n| 1 | 2 |"
let nsText = text as NSString
let tokens = MarkdownTokenizer.parseTokensViaAST(in: text)
let tableToken = try #require(tokens.first { $0.kind == .table })
let font = NSFont.systemFont(ofSize: 15)
let context = MarkdownStyler.StylingContext(
nsText: nsText,
tokens: tokens,
codeTokens: [],
activeTokenIndices: [],
baseFont: font,
layoutBridge: nil,
baseDefaultLineHeight: 18,
codeBackgroundColor: .windowBackgroundColor,
latexMarkerFont: font,
configuration: .default,
wikiLinkIDProvider: { _ in nil }
)
let attributes = MarkdownStyler.styleTables(context)
let stampedAnchor = try #require(attributes.first {
$0.attributes[.scrollableBlockFullRange] != nil
})
#expect(stampedAnchor.range.length == 1)
#expect(stampedAnchor.attributes[.scrollableBlockNaturalWidth] == nil)
let stampedRange = try #require(
stampedAnchor.attributes[.scrollableBlockFullRange] as? NSValue
).rangeValue
#expect(stampedRange == nsText.paragraphRange(for: tableToken.range))
}
}