diff --git a/PocketKit/Sources/Sync/Source.swift b/PocketKit/Sources/Sync/Source.swift index 7e51f987c..3771bd656 100644 --- a/PocketKit/Sources/Sync/Source.swift +++ b/PocketKit/Sources/Sync/Source.swift @@ -94,18 +94,11 @@ public protocol Source { } public extension Source { - func refreshSaves(completion: (() -> Void)?) { - self.refreshSaves(completion: completion) - } func refreshSaves() { self.refreshSaves(completion: nil) } - func refreshArchive(completion: (() -> Void)?) { - self.refreshArchive(completion: completion) - } - func refreshArchive() { self.refreshArchive(completion: nil) } diff --git a/PocketKit/Tests/PocketKitTests/Refresh/RefreshCoordinatorTests.swift b/PocketKit/Tests/PocketKitTests/Refresh/RefreshCoordinatorTests.swift index 6f9985ac3..d7ea8b347 100644 --- a/PocketKit/Tests/PocketKitTests/Refresh/RefreshCoordinatorTests.swift +++ b/PocketKit/Tests/PocketKitTests/Refresh/RefreshCoordinatorTests.swift @@ -62,7 +62,7 @@ class RefreshCoordinatorTests: XCTestCase { taskScheduler.stubRegisterHandler { handler = $2; return true } taskScheduler.stubSubmit { _ in } - source.stubRefreshSaves { _, completion in + source.stubRefreshSaves { completion in completion?() } @@ -84,7 +84,7 @@ class RefreshCoordinatorTests: XCTestCase { taskScheduler.stubRegisterHandler { handler = $2; return true } taskScheduler.stubSubmit { _ in } - source.stubRefreshSaves { _, completion in + source.stubRefreshSaves { completion in // completion callback never fires } @@ -105,8 +105,8 @@ class RefreshCoordinatorTests: XCTestCase { func test_receivingAppWillEnterForegroundNotification_refreshesSource_andResolvesUnresolvedSavedItems() { taskScheduler.stubRegisterHandler { _, _, _ in true } - source.stubRefreshSaves { _, _ in } - source.stubRefreshArchive { _, _ in } + source.stubRefreshSaves { _ in } + source.stubRefreshArchive { _ in } source.stubResolveUnresolvedSavedItems { } let coordinator = subject() @@ -120,10 +120,10 @@ class RefreshCoordinatorTests: XCTestCase { } func test_coordinator_whenNoSession_doesNotRefreshSavesArchive() { - source.stubRefreshSaves { _, _ in + source.stubRefreshSaves { _ in XCTFail("Should not fetch saves") } - source.stubRefreshArchive { _, _ in + source.stubRefreshArchive { _ in XCTFail("Should not fetch archive") } source.stubResolveUnresolvedSavedItems { diff --git a/PocketKit/Tests/PocketKitTests/SavedItemsListViewModelTests.swift b/PocketKit/Tests/PocketKitTests/SavedItemsListViewModelTests.swift index eaf340e23..174404075 100644 --- a/PocketKit/Tests/PocketKitTests/SavedItemsListViewModelTests.swift +++ b/PocketKit/Tests/PocketKitTests/SavedItemsListViewModelTests.swift @@ -336,7 +336,7 @@ class SavedItemsListViewModelTests: XCTestCase { } func test_refreshSaves_callsRetryImmediatelyOnSource() { - source.stubRefreshSaves { _, _ in } + source.stubRefreshSaves { _ in } source.stubRetryImmediately { } let viewModel = subject() diff --git a/PocketKit/Tests/PocketKitTests/Support/MockSource.swift b/PocketKit/Tests/PocketKitTests/Support/MockSource.swift index dada3e220..498926ee0 100644 --- a/PocketKit/Tests/PocketKitTests/Support/MockSource.swift +++ b/PocketKit/Tests/PocketKitTests/Support/MockSource.swift @@ -57,10 +57,9 @@ extension MockSource { // MARK: - Refresh Saves extension MockSource { private static let refreshSaves = "refreshSaves" - typealias RefreshSavesImpl = (Int, (() -> Void)?) -> Void + typealias RefreshSavesImpl = ((() -> Void)?) -> Void struct RefreshSavesCall { - let maxItems: Int let completion: (() -> Void)? } @@ -68,16 +67,16 @@ extension MockSource { implementations[Self.refreshSaves] = impl } - func refreshSaves(maxItems: Int, completion: (() -> Void)?) { + func refreshSaves(completion: (() -> Void)?) { guard let impl = implementations[Self.refreshSaves] as? RefreshSavesImpl else { fatalError("\(Self.self)#\(#function) has not been stubbed") } calls[Self.refreshSaves] = (calls[Self.refreshSaves] ?? []) + [ - RefreshSavesCall(maxItems: maxItems, completion: completion) + RefreshSavesCall(completion: completion) ] - impl(maxItems, completion) + impl(completion) } func refreshSavesCall(at index: Int) -> RefreshSavesCall? { @@ -92,10 +91,9 @@ extension MockSource { // MARK: - Refresh Archive extension MockSource { private static let refreshArchive = "refreshArchive" - typealias RefreshArchiveImpl = (Int, (() -> Void)?) -> Void + typealias RefreshArchiveImpl = ((() -> Void)?) -> Void struct RefreshArchiveCall { - let maxItems: Int let completion: (() -> Void)? } @@ -103,16 +101,16 @@ extension MockSource { implementations[Self.refreshArchive] = impl } - func refreshArchive(maxItems: Int, completion: (() -> Void)?) { + func refreshArchive(completion: (() -> Void)?) { guard let impl = implementations[Self.refreshArchive] as? RefreshArchiveImpl else { fatalError("\(Self.self)#\(#function) has not been stubbed") } calls[Self.refreshArchive] = (calls[Self.refreshArchive] ?? []) + [ - RefreshArchiveCall(maxItems: maxItems, completion: completion) + RefreshArchiveCall(completion: completion) ] - impl(maxItems, completion) + impl(completion) } func refreshArchiveCall(at index: Int) -> RefreshArchiveCall? {