Skip to content

Commit

Permalink
extract UserText and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaTardio committed Oct 18, 2023
1 parent d0ab91d commit 1a6c0d0
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 151 deletions.
8 changes: 0 additions & 8 deletions DuckDuckGo/MainViewController+Segues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,6 @@ extension MainViewController {
}
}

func segueToSettingsLogins() {
os_log(#function, log: .generalLog, type: .debug)
hideAllHighlightsIfNeeded()
launchSettings {
$0.openLogins()
}
}

private func launchSettings(completion: ((SettingsViewController) -> Void)? = nil) {
os_log(#function, log: .generalLog, type: .debug)
let storyboard = UIStoryboard(name: "Settings", bundle: nil)
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ extension SyncSettingsViewController: SyncManagementViewModelDelegate {
mainVC.segueToBookmarks()
}


func updateDeviceName(_ name: String) {
Task { @MainActor in
rootView.model.devices = []
Expand Down
2 changes: 0 additions & 2 deletions DuckDuckGo/SyncSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class SyncSettingsViewController: UIHostingController<SyncSettingsView> {

var cancellables = Set<AnyCancellable>()


// For some reason, on iOS 14, the viewDidLoad wasn't getting called so do some setup here
convenience init(appSettings: AppSettings = AppDependencyProvider.shared.appSettings) {
let viewModel = SyncSettingsViewModel()
Expand Down Expand Up @@ -160,7 +159,6 @@ class SyncSettingsViewController: UIHostingController<SyncSettingsView> {
lhs.isThisDevice
})
}


}

Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGoTests/AppSettingsMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import Foundation
@testable import DuckDuckGo

class AppSettingsMock: AppSettings {

var isSyncBookmarksPaused: Bool = false

var isSyncCredentialsPaused: Bool = false

var autofillCredentialsEnabled: Bool = false

Expand Down
28 changes: 28 additions & 0 deletions DuckDuckGoTests/SyncManagementViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ class SyncManagementViewModelTests: XCTestCase, SyncManagementViewModelDelegate
])
}

func testWhenManageBookmarksCalled_BookmarksVCIsLaunched() {
model.manageBookmarks()

// You can either test one individual call was made x number of times or check for a whole number of calls
monitor.assert(#selector(launchBookmarksViewController).description, calls: 1)
monitor.assertCalls([
#selector(launchBookmarksViewController).description: 1
])
}

func testWhenManageLogindCalled_AutofillVCIsLaunched() {
model.manageLogins()

// You can either test one individual call was made x number of times or check for a whole number of calls
monitor.assert(#selector(launchAutofillViewController).description, calls: 1)
monitor.assertCalls([
#selector(launchAutofillViewController).description: 1
])
}

// MARK: Delegate functions

func showSyncWithAnotherDeviceEnterText() {
Expand Down Expand Up @@ -148,6 +168,14 @@ class SyncManagementViewModelTests: XCTestCase, SyncManagementViewModelDelegate
monitor.incrementCalls(function: #function.cleaningFunctionName())
}

func launchBookmarksViewController() {
monitor.incrementCalls(function: #function.cleaningFunctionName())
}

func launchAutofillViewController() {
monitor.incrementCalls(function: #function.cleaningFunctionName())
}

}

// MARK: An idea... can be made more public if works out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,12 @@ struct UserText {
return "\"\(name)\" will no longer be able to access your synced data."
}

static let syncLimitExceededTitle = "⚠️ Sync Paused"
static let bookmarksLimitExceededDescription = "Bookmark limit exceeded. Delete some to resume syncing."
static let credentialsLimitExceededDescription = "Logins limit exceeded. Delete some to resume syncing."
static let bookmarksLimitExceededAction = "Manage Bookmarks"
static let credentialsLimitExceededAction = "Manage Logins"


}
// swiftlint:enable line_length
Loading

0 comments on commit 1a6c0d0

Please sign in to comment.