mirror of
https://github.com/bitwarden/ios.git
synced 2025-12-11 23:33:36 -06:00
82 lines
2.7 KiB
Swift
82 lines
2.7 KiB
Swift
// swiftlint:disable:this file_name
|
|
import BitwardenResources
|
|
import ViewInspector
|
|
import XCTest
|
|
|
|
@testable import BitwardenShared
|
|
|
|
class VaultUnlockSetupViewTests: BitwardenTestCase {
|
|
// MARK: Properties
|
|
|
|
var processor: MockProcessor<VaultUnlockSetupState, VaultUnlockSetupAction, VaultUnlockSetupEffect>!
|
|
var subject: VaultUnlockSetupView!
|
|
|
|
// MARK: Setup & Teardown
|
|
|
|
override func setUp() {
|
|
super.setUp()
|
|
|
|
processor = MockProcessor(state: VaultUnlockSetupState(accountSetupFlow: .createAccount))
|
|
|
|
subject = VaultUnlockSetupView(store: Store(processor: processor))
|
|
}
|
|
|
|
override func tearDown() {
|
|
super.tearDown()
|
|
|
|
processor = nil
|
|
subject = nil
|
|
}
|
|
|
|
// MARK: Tests
|
|
|
|
/// The view displays the set up later button when in the create account flow.
|
|
@MainActor
|
|
func test_accountSetupFlow_createAccount() async throws {
|
|
processor.state.accountSetupFlow = .createAccount
|
|
|
|
XCTAssertNoThrow(try subject.inspect().find(button: Localizations.setUpLater))
|
|
}
|
|
|
|
/// The view hides the set up later button when in the settings flow.
|
|
@MainActor
|
|
func test_accountSetupFlow_settings() async {
|
|
processor.state.accountSetupFlow = .settings
|
|
|
|
XCTAssertThrowsError(try subject.inspect().find(button: Localizations.setUpLater))
|
|
}
|
|
|
|
/// Tapping the continue button dispatches the continue flow action.
|
|
@MainActor
|
|
func test_continue_tap() async throws {
|
|
processor.state.biometricsStatus = .available(.faceID, enabled: true)
|
|
let button = try subject.inspect().find(asyncButton: Localizations.continue)
|
|
try await button.tap()
|
|
XCTAssertEqual(processor.effects.last, .continueFlow)
|
|
}
|
|
|
|
/// The continue button is enabled when one or more unlock methods are enabled.
|
|
@MainActor
|
|
func test_continue_enabled() throws {
|
|
var button = try subject.inspect().find(button: Localizations.continue)
|
|
XCTAssertTrue(button.isDisabled())
|
|
|
|
processor.state.biometricsStatus = .available(.faceID, enabled: true)
|
|
button = try subject.inspect().find(button: Localizations.continue)
|
|
XCTAssertFalse(button.isDisabled())
|
|
|
|
processor.state.biometricsStatus = .available(.faceID, enabled: false)
|
|
processor.state.isPinUnlockOn = true
|
|
button = try subject.inspect().find(button: Localizations.continue)
|
|
XCTAssertFalse(button.isDisabled())
|
|
}
|
|
|
|
/// Tapping the set up later button dispatches the set up later action.
|
|
@MainActor
|
|
func test_setUpLater_tap() throws {
|
|
let button = try subject.inspect().find(button: Localizations.setUpLater)
|
|
try button.tap()
|
|
XCTAssertEqual(processor.dispatchedActions.last, .setUpLater)
|
|
}
|
|
}
|