1
0
mirror of git://jb55.com/damus synced 2024-09-19 11:43:44 +00:00
damus/damusTests/NoteContentViewTests.swift
William Casarin cebd1f48ca ndb: switch to nostrdb notes
This is a refactor of the codebase to use a more memory-efficient
representation of notes. It should also be much faster at decoding since
we're using a custom C json parser now.

Changelog-Changed: Improved memory usage and performance when processing events
2023-08-03 13:20:36 -07:00

30 lines
1.2 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// NoteContentViewTests.swift
// damusTests
//
// Created by Daniel DAquino on 2023-08-02.
//
import XCTest
@testable import damus
class NoteContentViewTests: XCTestCase {
func testRenderBlocksWithNonLatinHashtags() {
let content = "Damusはかっこいいです #cool #かっこいい"
let note = NostrEvent(content: content, keypair: test_keypair, tags: [["t", "かっこいい"]])!
let parsed: Blocks = parse_note_content(content: .init(note: note, privkey: test_keypair.privkey))
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)")
}
}