damus

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

LikeTests.swift (2488B)


      1 //
      2 //  LikeTests.swift
      3 //  damusTests
      4 //
      5 //  Created by William Casarin on 2022-05-08.
      6 //
      7 
      8 import XCTest
      9 @testable import damus
     10 
     11 class LikeTests: XCTestCase {
     12 
     13     override func setUpWithError() throws {
     14         // Put setup code here. This method is called before the invocation of each test method in the class.
     15     }
     16 
     17     override func tearDownWithError() throws {
     18         // Put teardown code here. This method is called after the invocation of each test method in the class.
     19     }
     20 
     21     func testLikeHasNotification() throws {
     22         let cindy = Pubkey(hex: "9d9181f0aea6500e1f360e07b9f37e25c72169b5158ae78df53f295272b6b71c")!
     23         let bob = Pubkey(hex: "218837fe8c94a66ae33af277bcbda45a0319e7726220cd76171b9dd1a468af91")!
     24         let liked = NostrEvent(content: "awesome #[0] post",
     25                                keypair: test_keypair,
     26                                tags: [cindy.tag, bob.tag])!
     27         let id = liked.id
     28         let like_ev = make_like_event(keypair: test_keypair_full, liked: liked)!
     29 
     30         XCTAssertTrue(like_ev.referenced_pubkeys.contains(test_keypair.pubkey))
     31         XCTAssertTrue(like_ev.referenced_pubkeys.contains(cindy))
     32         XCTAssertTrue(like_ev.referenced_pubkeys.contains(bob))
     33         XCTAssertEqual(like_ev.last_refid()!, id)
     34     }
     35 
     36     func testToReactionEmoji() {
     37         let liked = NostrEvent(content: "awesome #[0] post", keypair: test_keypair, tags: [["p", "cindy"], ["e", "bob"]])!
     38 
     39         let emptyReaction = make_like_event(keypair: test_keypair_full, liked: liked, content: "")!
     40         let plusReaction = make_like_event(keypair: test_keypair_full, liked: liked, content: "+")!
     41         let minusReaction = make_like_event(keypair: test_keypair_full, liked: liked, content: "-")!
     42         let heartReaction = make_like_event(keypair: test_keypair_full, liked: liked, content: "❤️")!
     43         let thumbsUpReaction = make_like_event(keypair: test_keypair_full, liked: liked, content: "👍")!
     44         let shakaReaction = make_like_event(keypair: test_keypair_full, liked: liked, content: "🤙")!
     45 
     46         XCTAssertEqual(to_reaction_emoji(ev: emptyReaction), "❤️")
     47         XCTAssertEqual(to_reaction_emoji(ev: plusReaction), "❤️")
     48         XCTAssertEqual(to_reaction_emoji(ev: minusReaction), "👎")
     49         XCTAssertEqual(to_reaction_emoji(ev: heartReaction), "❤️")
     50         XCTAssertEqual(to_reaction_emoji(ev: thumbsUpReaction), "👍")
     51         XCTAssertEqual(to_reaction_emoji(ev: shakaReaction), "🤙")
     52     }
     53 
     54 }