damus

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

MutingTests.swift (1743B)


      1 //
      2 //  MutingTests.swift
      3 //  damusTests
      4 //
      5 //  Created by Daniel D’Aquino on 2024-05-06.
      6 //
      7 import Foundation
      8 
      9 import XCTest
     10 @testable import damus
     11 
     12 final class MutingTests: XCTestCase {
     13     func testWordMuting() {
     14         // Setup some test data
     15         let test_note = NostrEvent(
     16             content: "Nostr is the super app. Because it’s actually an ecosystem of apps, all of which make each other better. People haven’t grasped that yet. They will when it’s more accessible and onboarding is more straightforward and intuitive.",
     17             keypair: jack_keypair,
     18             createdAt: UInt32(Date().timeIntervalSince1970 - 100)
     19         )!
     20         let spammy_keypair = generate_new_keypair().to_keypair()
     21         let spammy_test_note = NostrEvent(
     22             content: "Some spammy airdrop just arrived! Why stack sats when you can get scammed instead with some random coin? Call 1-800-GET-SCAMMED to claim your airdrop today!",
     23             keypair: spammy_keypair,
     24             createdAt: UInt32(Date().timeIntervalSince1970 - 100)
     25         )!
     26         
     27         let mute_item: MuteItem = .word("airdrop", nil)
     28         let existing_mutelist = test_damus_state.mutelist_manager.event
     29 
     30         guard
     31             let full_keypair = test_damus_state.keypair.to_full(),
     32             let mutelist = create_or_update_mutelist(keypair: full_keypair, mprev: existing_mutelist, to_add: mute_item)
     33         else {
     34             return
     35         }
     36 
     37         test_damus_state.mutelist_manager.set_mutelist(mutelist)
     38         test_damus_state.postbox.send(mutelist)
     39         
     40         XCTAssert(test_damus_state.mutelist_manager.is_event_muted(spammy_test_note))
     41         XCTAssertFalse(test_damus_state.mutelist_manager.is_event_muted(test_note))
     42     }
     43 }