* Update copyright holding and dates * compound IDE Macros updated * update copyright * update copyrights done * update templates and README
54 lines
1.8 KiB
Swift
54 lines
1.8 KiB
Swift
//
|
|
// Copyright 2025 Element Creations Ltd.
|
|
// Copyright 2022-2025 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import XCTest
|
|
|
|
@testable import ElementX
|
|
|
|
@MainActor
|
|
class AppLockSetupBiometricsScreenViewModelTests: XCTestCase {
|
|
var appLockService: AppLockServiceMock!
|
|
var viewModel: AppLockSetupBiometricsScreenViewModelProtocol!
|
|
|
|
var context: AppLockSetupBiometricsScreenViewModelType.Context { viewModel.context }
|
|
|
|
override func setUp() {
|
|
AppSettings.resetAllSettings()
|
|
|
|
appLockService = AppLockServiceMock()
|
|
appLockService.underlyingIsEnabled = true
|
|
appLockService.underlyingBiometryType = .touchID
|
|
appLockService.enableBiometricUnlockReturnValue = .success(())
|
|
viewModel = AppLockSetupBiometricsScreenViewModel(appLockService: appLockService)
|
|
}
|
|
|
|
override func tearDown() {
|
|
AppSettings.resetAllSettings()
|
|
}
|
|
|
|
func testAllow() async throws {
|
|
// When allowing Touch/Face ID.
|
|
let deferred = deferFulfillment(viewModel.actions) { $0 == .continue }
|
|
context.send(viewAction: .allow)
|
|
try await deferred.fulfill()
|
|
|
|
// Then the service should now have biometric unlock enabled.
|
|
XCTAssertEqual(appLockService.enableBiometricUnlockCallsCount, 1)
|
|
}
|
|
|
|
func testSkip() async throws {
|
|
// When skipping biometrics.
|
|
let deferred = deferFulfillment(viewModel.actions) { $0 == .continue }
|
|
context.send(viewAction: .skip)
|
|
try await deferred.fulfill()
|
|
|
|
// Then the service should now have biometric unlock enabled.
|
|
XCTAssertEqual(appLockService.enableBiometricUnlockCallsCount, 0)
|
|
}
|
|
}
|