damus

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

commit cf3a9a576d339afc68aa61bbd3388a7bdbacc4be
parent e397fc069bce94054bcf5f165151d65891ac5d27
Author: William Casarin <jb55@jb55.com>
Date:   Sun,  6 Aug 2023 13:49:26 -0700

test: move existing url tests to UrlTests

Diffstat:
MdamusTests/ReplyTests.swift | 22----------------------
MdamusTests/UrlTests.swift | 30++++++++++++++++++++++++++++++
MdamusTests/damusTests.swift | 8--------
3 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/damusTests/ReplyTests.swift b/damusTests/ReplyTests.swift @@ -36,28 +36,6 @@ class ReplyTests: XCTestCase { XCTAssertEqual(ref.is_mention, .some(.init(note_id: evid))) } - func testUrlAnchorsAreNotHashtags() { - let content = "this is my link: https://jb55.com/index.html#buybitcoin this is not a hashtag!" - let blocks = parse_post_blocks(content: content) - - XCTAssertEqual(blocks.count, 3) - XCTAssertEqual(blocks[0].is_text, "this is my link: ") - XCTAssertEqual(blocks[1].is_url, URL(string: "https://jb55.com/index.html#buybitcoin")!) - XCTAssertEqual(blocks[2].is_text, " this is not a hashtag!") - } - - func testLinkIsNotAHashtag() { - let link = "https://github.com/damus-io/damus/blob/b7513f28fa1d31c2747865067256ad1d7cf43aac/damus/Nostr/NostrEvent.swift#L560" - - let content = "my \(link) link" - let blocks = parse_post_blocks(content: content) - - XCTAssertEqual(blocks.count, 3) - XCTAssertEqual(blocks[0].is_text, "my ") - XCTAssertEqual(blocks[1].is_url, URL(string: link)!) - XCTAssertEqual(blocks[2].is_text, " link") - } - func testAtAtEnd() { let content = "what @" let blocks = parse_post_blocks(content: content) diff --git a/damusTests/UrlTests.swift b/damusTests/UrlTests.swift @@ -25,4 +25,34 @@ final class UrlTests: XCTestCase { XCTAssertEqual(url1.url.absoluteString, "wss://jb55.com") } + func testLinkIsNotAHashtag() { + let link = "https://github.com/damus-io/damus/blob/b7513f28fa1d31c2747865067256ad1d7cf43aac/damus/Nostr/NostrEvent.swift#L560" + + let content = "my \(link) link" + let blocks = parse_post_blocks(content: content) + + XCTAssertEqual(blocks.count, 3) + XCTAssertEqual(blocks[0].is_text, "my ") + XCTAssertEqual(blocks[1].is_url, URL(string: link)!) + XCTAssertEqual(blocks[2].is_text, " link") + } + + func testParseUrlUpper() { + let parsed = parse_note_content(content: .content("a HTTPS://jb55.COM b", nil)).blocks + + XCTAssertNotNil(parsed) + XCTAssertEqual(parsed.count, 3) + XCTAssertEqual(parsed[1].is_url?.absoluteString, "HTTPS://jb55.COM") + } + + func testUrlAnchorsAreNotHashtags() { + let content = "this is my link: https://jb55.com/index.html#buybitcoin this is not a hashtag!" + let blocks = parse_post_blocks(content: content) + + XCTAssertEqual(blocks.count, 3) + XCTAssertEqual(blocks[0].is_text, "this is my link: ") + XCTAssertEqual(blocks[1].is_url, URL(string: "https://jb55.com/index.html#buybitcoin")!) + XCTAssertEqual(blocks[2].is_text, " this is not a hashtag!") + } + } diff --git a/damusTests/damusTests.swift b/damusTests/damusTests.swift @@ -97,14 +97,6 @@ class damusTests: XCTestCase { XCTAssertEqual(got2, ["a", "b", "c"]) } - func testParseUrlUpper() { - let parsed = parse_note_content(content: .content("a HTTPS://jb55.COM b", nil)).blocks - - XCTAssertNotNil(parsed) - XCTAssertEqual(parsed.count, 3) - XCTAssertEqual(parsed[1].is_url?.absoluteString, "HTTPS://jb55.COM") - } - func testBech32Url() { let parsed = decode_nostr_uri("nostr:npub1xtscya34g58tk0z605fvr788k263gsu6cy9x0mhnm87echrgufzsevkk5s")