damus

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

commit f6f7d13f1296743a4c9c95280092ce5e60d82e51
parent 6ee0be40e9d49318cb8c23b27bb12b20a0d23dcc
Author: Grimless <kyle@kyleroucis.com>
Date:   Fri,  1 Sep 2023 11:40:27 -0400

Properly implement top-level tests and fix one test using the wrong Block conversion property

Closes: https://github.com/damus-io/damus/pull/1528
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
MdamusTests/ReplyTests.swift | 2+-
MdamusTests/damusTests.swift | 19++++++++++++++-----
2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/damusTests/ReplyTests.swift b/damusTests/ReplyTests.swift @@ -41,7 +41,7 @@ class ReplyTests: XCTestCase { let blocks = parse_post_blocks(content: content) XCTAssertEqual(blocks.count, 1) - XCTAssertEqual(blocks[0].asString, "what @") + XCTAssertEqual(blocks[0].asText, "what @") } func testHashtagsInQuote() { diff --git a/damusTests/damusTests.swift b/damusTests/damusTests.swift @@ -159,8 +159,13 @@ class damusTests: XCTestCase { XCTAssertNotNil(parsed) XCTAssertEqual(parsed.count, 2) -// XCTAssertEqual(parsed[0].is_url?.absoluteString, "https://jb55.com") -// XCTAssertEqual(parsed[1].is_text, " br") + + let testURL = URL(string: "https://jb55.com") + XCTAssertNotNil(testURL) + + XCTAssertEqual(parsed[0].asURL, testURL) + + XCTAssertEqual(parsed[1].asText, " br") } func testNoParseUrlWithOnlyWhitespace() { @@ -168,15 +173,19 @@ class damusTests: XCTestCase { let parsed = parse_note_content(content: .content(testString,nil)).blocks XCTAssertNotNil(parsed) -// XCTAssertEqual(parsed[0].is_text, testString) + XCTAssertFalse(parsed[0].isURL) + XCTAssertEqual(parsed[0].asText, testString) } func testNoParseUrlTrailingCharacters() { let testString = "https://foo.bar, " let parsed = parse_note_content(content: .content(testString,nil)).blocks + let testURL = URL(string: "https://foo.bar") + XCTAssertNotNil(testURL) + XCTAssertNotNil(parsed) -// XCTAssertEqual(parsed[0].is_url?.absoluteString, "https://foo.bar") + XCTAssertEqual(parsed[0].asURL, testURL) } @@ -210,7 +219,7 @@ class damusTests: XCTestCase { XCTAssertNotNil(parsed) XCTAssertEqual(parsed.count, 1) -// XCTAssertEqual(parsed[0].is_text, "there is no mention here") + XCTAssertEqual(parsed[0].asText, "there is no mention here") guard case .text(let txt) = parsed[0] else { XCTAssertTrue(false)