damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 8d14fdffb576e4f9b635ec5f8899dd354b9e5441
parent 0c95071de75f8c81a391a0f644cf64dafed06407
Author: William Casarin <jb55@jb55.com>
Date:   Sun, 16 Jul 2023 11:00:19 -0700

content: add utf8 char at url left boundary test

Diffstat:
AdamusTests/ContentParserTests.swift | 27+++++++++++++++++++++++++++
MdamusTests/Models/DamusParseContentTests.swift | 15+++++++++++++--
2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/damusTests/ContentParserTests.swift b/damusTests/ContentParserTests.swift @@ -0,0 +1,27 @@ +// +// ContentParserTests.swift +// damusTests +// +// Created by William Casarin on 2023-07-16. +// + +import XCTest + +final class ContentParserTests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testPerformanceExample() throws { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/damusTests/Models/DamusParseContentTests.swift b/damusTests/Models/DamusParseContentTests.swift @@ -8,7 +8,7 @@ import XCTest @testable import damus -class DamusParseContentTests: XCTestCase { +class ContentParserTests: XCTestCase { private let decoder = JSONDecoder() @@ -19,7 +19,18 @@ class DamusParseContentTests: XCTestCase { override func tearDownWithError() throws { // Put teardown code here. This method is called after the invocation of each test method in the class. } - + + func test_url_parsing_with_emoji() throws { + let url = "https://media.tenor.com/5MibLt95scAAAAAC/%ED%98%BC%ED%8C%8C%EB%A7%9D-%ED%94%BC%EC%9E%90.gif" + let content = "gm 🤙\(url)" + + let blocks = parse_note_content(content: content, tags: []).blocks + XCTAssertEqual(blocks.count, 2) + XCTAssertEqual(blocks[0], .text("gm 🤙")) + XCTAssertEqual(blocks[1], .url(URL(string: url)!)) + } + + func test_damus_parse_content_can_parse_mention_without_white_space_at_front() throws { var bs = note_blocks() bs.num_blocks = 0;