Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaTardio committed Nov 27, 2023
1 parent acfa3b3 commit 09738ac
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 152 deletions.
49 changes: 40 additions & 9 deletions DuckDuckGoTests/SyncManagementViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ class SyncManagementViewModelTests: XCTestCase, SyncManagementViewModelDelegate
XCTAssertNotNil(caprturedOptionModel)
}

func testWhenShowRecoveryPDFPressed_ShowRecoveryPDFIsShown() {
model.delegate?.showRecoveryPDF()

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

func testWhenScanQRCodePressed_ThenSyncWithAnotherDeviceViewIsShown() {
model.scanQRCode()

Expand All @@ -52,23 +62,34 @@ class SyncManagementViewModelTests: XCTestCase, SyncManagementViewModelDelegate
])
}

func testWhenSyncIsNotSetup_EnterTextCodePressed_ThenSyncWithAnotherDeviceEnterTextViewIsShown() {
model.showEnterTextView()
func testWhenCopyCodePressed_CodeIsCopied() {
model.copyCode()

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

func testWhenRecoverYourDataPressed_RecoverDataViewIsShown() {
model.showRecoverDataView()

func testWhenManageBookmarkPressed_BookmarkVCIsLaunched() {
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(showRecoverData).description, calls: 1)
monitor.assert(#selector(launchBookmarksViewController).description, calls: 1)
monitor.assertCalls([
#selector(showRecoverData).description: 1
#selector(launchBookmarksViewController).description: 1
])
}

func testWhenManageLoginsPressed_LoginsVCIsLaunched() {
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
])
}

Expand Down Expand Up @@ -102,13 +123,23 @@ class SyncManagementViewModelTests: XCTestCase, SyncManagementViewModelDelegate
])
}


func testWhenRecoverSyncDataPressed_RecoverDataViewShown() {
model.recoverSyncDataPressed()

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

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

func createAccountAndStartSyncing(optionsViewModel: SyncSettingsViewModel) {
func createAccountAndStartSyncing(optionsViewModel: SyncSettingsViewModel) {
createAccountAndStartSyncingCalled = true
caprturedOptionModel = optionsViewModel
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public protocol SyncManagementViewModelDelegate: AnyObject {

func showRecoverData()
func showSyncWithAnotherDevice()
func showSyncWithAnotherDeviceEnterText()
func showRecoveryPDF()
func shareRecoveryPDF()
func createAccountAndStartSyncing(optionsViewModel: SyncSettingsViewModel)
Expand Down Expand Up @@ -121,10 +120,6 @@ public class SyncSettingsViewModel: ObservableObject {
delegate?.showSyncWithAnotherDevice()
}

func showEnterTextView() {
delegate?.showSyncWithAnotherDeviceEnterText()
}

func createEditDeviceModel(_ device: Device) -> EditDeviceViewModel {
return EditDeviceViewModel(device: device) { [weak self] newValue in
self?.delegate?.updateDeviceName(newValue.name)
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 09738ac

Please sign in to comment.