Files
ichmagmaus111andClaude Opus 5.5 0622057a4f Ghostgram: open-source release
Ghostgram for iOS, rebuilt from scratch on Telegram iOS 13.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 17:57:09 +01:00

35 lines
1.3 KiB
Swift

#if canImport(UIKit)
import XCTest
import UIKit
@testable import RichTextEditorUIKit
import RichTextEditorCore
final class SpellCheckRenderTests: XCTestCase {
private func makeCanvas(_ text: String) -> DocumentCanvasView {
let v = DocumentCanvasView()
v.setBlocks([.paragraph(ParagraphBlock(id: BlockID("p"), runs: [TextRun(text: text)]))], width: 320)
v.frame = CGRect(x: 0, y: 0, width: 320, height: 600); v.layoutIfNeeded()
return v
}
func test_underlineRects_nonEmptyOverFlaggedWord() {
let v = makeCanvas("hello wrold today")
let base = v.boxes[0].textStart
v.applyNativeAnnotations(global: NSRange(location: base + 6, length: 5), style: .spelling) // "wrold"
let rects = v.spellingUnderlineRects()
XCTAssertFalse(rects.isEmpty)
// Each rect is a thin baseline line (height ~1pt) and sits inside the canvas.
for r in rects { XCTAssertLessThanOrEqual(r.rect.height, 3); XCTAssertGreaterThan(r.rect.width, 0) }
}
func test_underlineRects_emptyWhenNothingFlagged() {
let v = makeCanvas("all good words")
XCTAssertTrue(v.spellingUnderlineRects().isEmpty)
}
func test_themeDefault_misspellingIsSystemRed() {
XCTAssertEqual(RichTextEditorTheme.default.misspellingUnderline, .systemRed)
}
}
#endif