2022-05-09 02:01:42 +00:00
|
|
|
//
|
|
|
|
// LikeTests.swift
|
|
|
|
// damusTests
|
|
|
|
//
|
|
|
|
// Created by William Casarin on 2022-05-08.
|
|
|
|
//
|
|
|
|
|
|
|
|
import XCTest
|
|
|
|
@testable import damus
|
|
|
|
|
|
|
|
class LikeTests: 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 testLikeHasNotification() throws {
|
2023-07-26 15:46:44 +00:00
|
|
|
let cindy = Pubkey(hex: "9d9181f0aea6500e1f360e07b9f37e25c72169b5158ae78df53f295272b6b71c")!
|
|
|
|
let bob = Pubkey(hex: "218837fe8c94a66ae33af277bcbda45a0319e7726220cd76171b9dd1a468af91")!
|
|
|
|
let liked = NostrEvent(content: "awesome #[0] post",
|
|
|
|
keypair: test_keypair,
|
|
|
|
tags: [cindy.tag, bob.tag])!
|
2022-05-09 02:01:42 +00:00
|
|
|
let id = liked.id
|
2023-07-25 15:58:06 +00:00
|
|
|
let like_ev = make_like_event(keypair: test_keypair_full, liked: liked)!
|
|
|
|
|
2023-07-26 15:46:44 +00:00
|
|
|
XCTAssertTrue(like_ev.referenced_pubkeys.contains(test_keypair.pubkey))
|
|
|
|
XCTAssertTrue(like_ev.referenced_pubkeys.contains(cindy))
|
|
|
|
XCTAssertTrue(like_ev.referenced_pubkeys.contains(bob))
|
|
|
|
XCTAssertEqual(like_ev.last_refid()!, id)
|
2022-05-09 02:01:42 +00:00
|
|
|
}
|
|
|
|
|
2023-05-16 14:54:04 +00:00
|
|
|
func testToReactionEmoji() {
|
2023-07-25 15:58:06 +00:00
|
|
|
let liked = NostrEvent(content: "awesome #[0] post", keypair: test_keypair, tags: [["p", "cindy"], ["e", "bob"]])!
|
|
|
|
|
|
|
|
let emptyReaction = make_like_event(keypair: test_keypair_full, liked: liked, content: "")!
|
|
|
|
let plusReaction = make_like_event(keypair: test_keypair_full, liked: liked, content: "+")!
|
|
|
|
let minusReaction = make_like_event(keypair: test_keypair_full, liked: liked, content: "-")!
|
|
|
|
let heartReaction = make_like_event(keypair: test_keypair_full, liked: liked, content: "❤️")!
|
|
|
|
let thumbsUpReaction = make_like_event(keypair: test_keypair_full, liked: liked, content: "👍")!
|
|
|
|
let shakaReaction = make_like_event(keypair: test_keypair_full, liked: liked, content: "🤙")!
|
2023-05-16 14:54:04 +00:00
|
|
|
|
|
|
|
XCTAssertEqual(to_reaction_emoji(ev: emptyReaction), "❤️")
|
|
|
|
XCTAssertEqual(to_reaction_emoji(ev: plusReaction), "❤️")
|
|
|
|
XCTAssertEqual(to_reaction_emoji(ev: minusReaction), "👎")
|
|
|
|
XCTAssertEqual(to_reaction_emoji(ev: heartReaction), "❤️")
|
|
|
|
XCTAssertEqual(to_reaction_emoji(ev: thumbsUpReaction), "👍")
|
|
|
|
XCTAssertEqual(to_reaction_emoji(ev: shakaReaction), "🤙")
|
|
|
|
}
|
|
|
|
|
2022-05-09 02:01:42 +00:00
|
|
|
}
|