MockDamusState.swift (2250B)
1 // 2 // MockDamusState.swift 3 // damusTests 4 // 5 // Created by Daniel D’Aquino on 2023-10-13. 6 // 7 8 import Foundation 9 @testable import damus 10 import EmojiPicker 11 12 // Generates a test damus state with configurable mock parameters 13 func generate_test_damus_state( 14 mock_profile_info: [Pubkey: Profile]? 15 ) -> DamusState { 16 // Create a unique temporary directory 17 let ndb = Ndb.test 18 let our_pubkey = test_pubkey 19 let pool = RelayPool(ndb: ndb) 20 let settings = UserSettingsStore() 21 22 let profiles: Profiles = { 23 guard let mock_profile_info, let profiles: Profiles = MockProfiles(mocked_profiles: mock_profile_info, ndb: ndb) else { 24 return Profiles.init(ndb: ndb) 25 } 26 return profiles 27 }() 28 29 let mutelist_manager = MutelistManager(user_keypair: test_keypair) 30 let damus = DamusState(keypair: test_keypair, 31 likes: .init(our_pubkey: our_pubkey), 32 boosts: .init(our_pubkey: our_pubkey), 33 contacts: .init(our_pubkey: our_pubkey), mutelist_manager: mutelist_manager, 34 profiles: profiles, 35 dms: .init(our_pubkey: our_pubkey), 36 previews: .init(), 37 zaps: .init(our_pubkey: our_pubkey), 38 lnurls: .init(), 39 settings: settings, 40 relay_filters: .init(our_pubkey: our_pubkey), 41 relay_model_cache: .init(), 42 drafts: .init(), 43 events: .init(ndb: ndb), 44 bookmarks: .init(pubkey: our_pubkey), 45 replies: .init(our_pubkey: our_pubkey), 46 wallet: .init(settings: settings), 47 nav: .init(), 48 music: .init(onChange: {_ in }), 49 video: .init(), 50 ndb: ndb, 51 quote_reposts: .init(our_pubkey: our_pubkey), 52 emoji_provider: DefaultEmojiProvider(showAllVariations: false), 53 favicon_cache: .init() 54 ) 55 56 return damus 57 }