commit 7fc270725f3b68dc10b0bff57e15a7e95706c4b7
parent 7b73a54de587945b88bf52463abfc65ad9fc4395
Author: William Casarin <jb55@jb55.com>
Date: Thu, 13 Jul 2023 07:11:15 -0700
test: add newline mention test
This is currently passing but it shouldn't be. This is because we are
not testing the build_post function directly. We will do this soon.
Diffstat:
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/damusTests/ReplyTests.swift b/damusTests/ReplyTests.swift
@@ -130,6 +130,29 @@ class ReplyTests: XCTestCase {
let mentions = blocks.filter { $0.is_mention != nil }
XCTAssertEqual(mentions.count, 1)
}
+
+ func testNewlineMentions() throws {
+ let pk = "npub1xtscya34g58tk0z605fvr788k263gsu6cy9x0mhnm87echrgufzsevkk5s"
+ guard let hex_pk = bech32_pubkey_decode(pk) else {
+ return
+ }
+ let content = """
+ @\(pk)
+ @\(pk)
+ """
+
+ let blocks = parse_mentions(content: content, tags: []).blocks
+
+ let rendered = render_blocks(blocks: blocks)
+ let expected_render = "nostr:\(pk)\nnostr:\(pk)"
+
+ XCTAssertEqual(rendered, expected_render)
+
+ XCTAssertEqual(blocks.count, 3)
+ XCTAssertEqual(blocks[0].is_mention, .pubkey(hex_pk))
+ XCTAssertEqual(blocks[1].is_text, "\n")
+ XCTAssertEqual(blocks[2].is_mention, .pubkey(hex_pk))
+ }
func testThreadedReply() throws {
let content = "this is some content"