commit 85930df8e3cb65a53209b21f206998b48483f29e
parent cf3a9a576d339afc68aa61bbd3388a7bdbacc4be
Author: Joel Klabo <joelklabo@gmail.com>
Date: Sun, 6 Aug 2023 13:50:58 -0700
tests: add url parens tests
Diffstat:
1 file changed, 24 insertions(+), 0 deletions(-)
diff --git a/damusTests/UrlTests.swift b/damusTests/UrlTests.swift
@@ -25,6 +25,30 @@ final class UrlTests: XCTestCase {
XCTAssertEqual(url1.url.absoluteString, "wss://jb55.com")
}
+ func testParseUrlTrailingParenthesis() {
+ let testString = "https://en.m.wikipedia.org/wiki/Delicious_(website)"
+ let parsed = parse_note_content(content: .content(testString, nil)).blocks
+
+ XCTAssertNotNil(parsed)
+ XCTAssertEqual(parsed[0].is_url?.absoluteString, testString)
+ }
+
+ func testParseUrlTrailingParenthesisAndInitialParenthesis() {
+ let testString = "( https://en.m.wikipedia.org/wiki/Delicious_(website)"
+ let parsed = parse_note_content(content: .content(testString, nil)).blocks
+
+ XCTAssertNotNil(parsed)
+ XCTAssertEqual(parsed[1].is_url?.absoluteString, "https://en.m.wikipedia.org/wiki/Delicious_(website)")
+ }
+
+ func testParseUrlTrailingParenthesisShouldntParse() {
+ let testString = "(https://jb55.com)"
+ let parsed = parse_note_content(content: .content(testString, nil)).blocks
+
+ XCTAssertNotNil(parsed)
+ XCTAssertEqual(parsed[1].is_url?.absoluteString, "https://jb55.com")
+ }
+
func testLinkIsNotAHashtag() {
let link = "https://github.com/damus-io/damus/blob/b7513f28fa1d31c2747865067256ad1d7cf43aac/damus/Nostr/NostrEvent.swift#L560"