test: Add basic snapshot test coverage for EventView
This commit adds a basic snapshot test for EventView, and also adds some testing infrastructure to help with mocking NostrDB behavior. Test ---- PASS Device: iOS 17.0 Simulator iOS: 17.0 Damus: This commit Steps: Run `EventViewTests` Results: Snapshot matches baseline reference added
This commit is contained in:
committed by
William Casarin
parent
edb23e4e70
commit
3b76fcb743
28
damusTests/Mocking/MockProfiles.swift
Normal file
28
damusTests/Mocking/MockProfiles.swift
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// MockProfiles.swift
|
||||
// damusTests
|
||||
//
|
||||
// Created by Daniel D’Aquino on 2023-10-13.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@testable import damus
|
||||
|
||||
// A Mockable `Profiles` class that can be used for testing.
|
||||
// Note: Not all methods are mocked. You might need to implement a method depending on the test you are writing.
|
||||
class MockProfiles: Profiles {
|
||||
var mocked_profiles: [Pubkey: Profile] = [:]
|
||||
var ndb: Ndb
|
||||
|
||||
init?(mocked_profiles: [Pubkey : Profile], ndb: Ndb) {
|
||||
self.mocked_profiles = mocked_profiles
|
||||
self.ndb = ndb
|
||||
super.init(ndb: ndb)
|
||||
}
|
||||
|
||||
override func lookup(id: Pubkey) -> NdbTxn<Profile?> {
|
||||
return NdbTxn(ndb: self.ndb) { txn in
|
||||
return self.mocked_profiles[id]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user