IOS-1542 Tracking the error when running the test. IOS-1542
authorDirk Zimmermann <dz@pep.security>
Wed, 24 Apr 2019 12:43:18 +0200
branchIOS-1542
changeset 8367f75f27b477c6
parent 8366 3e8adbb87f02
child 8368 94cad6139b72
IOS-1542 Tracking the error when running the test.
pEpForiOSTests/Models/Settings/AccountSettingsViewModelTest.swift
     1.1 --- a/pEpForiOSTests/Models/Settings/AccountSettingsViewModelTest.swift	Wed Apr 24 12:43:18 2019 +0200
     1.2 +++ b/pEpForiOSTests/Models/Settings/AccountSettingsViewModelTest.swift	Wed Apr 24 12:43:18 2019 +0200
     1.3 @@ -74,11 +74,21 @@
     1.4                                                                port: "123",
     1.5                                                                transport: "StartTls")
     1.6  
     1.7 +        let verifyExpectation =
     1.8 +            expectation(description: AccountVerificationResultDelegateMock.DID_VERIFY_EXPECTATION)
     1.9 +
    1.10 +        let delegate = AccountVerificationResultDelegateMock()
    1.11 +        delegate.expectationDidVerifyCalled = verifyExpectation
    1.12 +        viewModel.delegate = delegate
    1.13 +
    1.14          viewModel.update(loginName: login,
    1.15                           name: name,
    1.16                           password: password,
    1.17                           imap: server,
    1.18                           smtp: server)
    1.19 +
    1.20 +        waitForExpectations(timeout: UnitTestUtils.waitTime)
    1.21 +
    1.22          // TODO: What to test here?
    1.23          /*
    1.24          let smtp = viewModel.account.smtpServer
    1.25 @@ -140,8 +150,24 @@
    1.26  class AccountVerificationResultDelegateMock: AccountVerificationResultDelegate {
    1.27      static let DID_VERIFY_EXPECTATION = "DID_VERIFY_CALLED"
    1.28      var expectationDidVerifyCalled: XCTestExpectation?
    1.29 +    var error: Error? = nil
    1.30  
    1.31      func didVerify(result: AccountVerificationResult, accountInput: VerifiableAccountProtocol?) {
    1.32 +        switch result {
    1.33 +        case .ok:
    1.34 +            self.error = nil
    1.35 +        case .noImapConnectData, .noSmtpConnectData:
    1.36 +            let theError = NSError(
    1.37 +                domain: #function,
    1.38 +                code: 777,
    1.39 +                userInfo: [NSLocalizedDescriptionKey: "SMTP/IMAP ERROR"])
    1.40 +            self.error = theError
    1.41 +        case .imapError(let error):
    1.42 +            self.error = error
    1.43 +        case .smtpError(let error):
    1.44 +            self.error = error
    1.45 +        }
    1.46 +
    1.47          guard let expectation = expectationDidVerifyCalled else {
    1.48              XCTFail()
    1.49              return