posting: don't prepad user tag if its a newline

This fixes one more edgecase with the tag prepend logic.
This commit is contained in:
William Casarin
2023-07-17 10:45:05 -07:00
parent fe82134a75
commit ff70cb7ebf
2 changed files with 32 additions and 4 deletions

View File

@@ -224,6 +224,26 @@ class ReplyTests: XCTestCase {
XCTAssertEqual(new_post.string, "😎 @jb55 ")
}
func testComposedMentionNewline() throws {
let content = """
@jb55
"""
let profile = Profile(name: "jb55")
let tag = user_tag_attr_string(profile: profile, pubkey: "pk")
let appended = append_user_tag(tag: tag, post: .init(string: content), word_range: .init(1...5))
let new_post = appended.post
try new_post.testAttributes(conditions: [
{ let link = $0[.link] as? String; XCTAssertNil(link) },
{ let link = $0[.link] as! String; XCTAssertEqual(link, "damus:nostr:pk") },
{ let link = $0[.link] as? String; XCTAssertNil(link) },
])
XCTAssertEqual(new_post.string, "\n@jb55 ")
}
func testComposedMention() throws {
let content = "@jb55"