fix: Add MockCheckServerReachabilityUseCase implementation
This commit is contained in:
parent
ef8ebd6f00
commit
bf3ee7a1d7
@ -22,7 +22,7 @@ class SimpleAPI {
|
||||
}
|
||||
|
||||
do {
|
||||
let (data, response) = try await URLSession.shared.data(for: request)
|
||||
let (_, response) = try await URLSession.shared.data(for: request)
|
||||
if let httpResponse = response as? HTTPURLResponse,
|
||||
200...299 ~= httpResponse.statusCode {
|
||||
logger.info("Server is reachable")
|
||||
|
||||
@ -9,6 +9,10 @@ import Foundation
|
||||
import Combine
|
||||
|
||||
class MockUseCaseFactory: UseCaseFactory {
|
||||
func makeCheckServerReachabilityUseCase() -> any PCheckServerReachabilityUseCase {
|
||||
MockCheckServerReachabilityUseCase()
|
||||
}
|
||||
|
||||
func makeOfflineBookmarkSyncUseCase() -> any POfflineBookmarkSyncUseCase {
|
||||
MockOfflineBookmarkSyncUseCase()
|
||||
}
|
||||
@ -224,6 +228,16 @@ class MockSaveCardLayoutUseCase: PSaveCardLayoutUseCase {
|
||||
}
|
||||
}
|
||||
|
||||
class MockCheckServerReachabilityUseCase: PCheckServerReachabilityUseCase {
|
||||
func execute() async -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func getServerInfo() async throws -> ServerInfo {
|
||||
return ServerInfo(version: "1.0.0", buildDate: nil, userAgent: nil, isReachable: true)
|
||||
}
|
||||
}
|
||||
|
||||
extension Bookmark {
|
||||
static let mock: Bookmark = .init(
|
||||
id: "123", title: "title", url: "https://example.com", href: "https://example.com", description: "description", authors: ["Tom"], created: "", published: "", updated: "", siteName: "example.com", site: "https://example.com", readingTime: 2, wordCount: 20, hasArticle: true, isArchived: false, isDeleted: false, isMarked: true, labels: ["Test"], lang: "EN", loaded: false, readProgress: 0, documentType: "", state: 0, textDirection: "ltr", type: "", resources: .init(article: nil, icon: nil, image: nil, log: nil, props: nil, thumbnail: nil)
|
||||
|
||||
@ -12,7 +12,7 @@ class OfflineBookmarksViewModel {
|
||||
private var completionTimerActive = false
|
||||
|
||||
init(_ factory: UseCaseFactory = DefaultUseCaseFactory.shared) {
|
||||
self.syncUseCase = factory.makeOfflineBookmarkSyncUseCase()
|
||||
self.syncUseCase = factory.makeOfflineBookmarkSyncUseCase()
|
||||
setupBindings()
|
||||
refreshState()
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ struct PadSidebarView: View {
|
||||
@State private var selectedTag: BookmarkLabel?
|
||||
@EnvironmentObject var playerUIState: PlayerUIState
|
||||
@EnvironmentObject var appSettings: AppSettings
|
||||
@State private var offlineBookmarksViewModel = OfflineBookmarksViewModel(syncUseCase: DefaultUseCaseFactory.shared.makeOfflineBookmarkSyncUseCase())
|
||||
@State private var offlineBookmarksViewModel = OfflineBookmarksViewModel()
|
||||
|
||||
private let sidebarTabs: [SidebarTab] = [.search, .all, .unread, .favorite, .archived, .article, .videos, .pictures, .tags]
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user