Add unit tests surrounding creation of posts with non-latin hashtags, as well as the rendering of non-latin hashtag
Signed-off-by: Daniel D‘Aquino <daniel@daquino.me> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
William Casarin
parent
f0b8dcc5e9
commit
ef5a3030a6
27
damusTests/NoteContentViewTests.swift
Normal file
27
damusTests/NoteContentViewTests.swift
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// NoteContentViewTests.swift
|
||||
// damusTests
|
||||
//
|
||||
// Created by Daniel D’Aquino on 2023-08-02.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import damus
|
||||
|
||||
class NoteContentViewTests: XCTestCase {
|
||||
func testRenderBlocksWithNonLatinHashtags() {
|
||||
let parsed: Blocks = parse_note_content(content: "Damusはかっこいいです #cool #かっこいい", tags: [["t", "かっこいい"]])
|
||||
|
||||
let testState = test_damus_state()
|
||||
|
||||
let text: NoteArtifactsSeparated = render_blocks(blocks: parsed, profiles: testState.profiles)
|
||||
let attributedText: AttributedString = text.content.attributed
|
||||
|
||||
let runs: AttributedString.Runs = attributedText.runs
|
||||
let runArray: [AttributedString.Runs.Run] = Array(runs)
|
||||
print(runArray.description)
|
||||
XCTAssertEqual(runArray[1].link?.absoluteString, "damus:t:cool", "Latin-character hashtag is missing. Runs description :\(runArray.description)")
|
||||
XCTAssertEqual(runArray[3].link?.absoluteString.removingPercentEncoding!, "damus:t:かっこいい", "Non-latin-character hashtag is missing. Runs description :\(runArray.description)")
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user